Package javax.vecmath

Examples of javax.vecmath.Vector2d.sub()


        for (int i = 0; i < fWorld.objects.size(); i++) {
          FysixObject fo1 = (FysixObject) fWorld.objects.get(i);                          
          for (int j = i+1; j < fWorld.objects.size(); j++) {
              FysixObject fo2 = (FysixObject) fWorld.objects.get(j);
              Vector2d dist = new Vector2d(0,0);
              dist.sub(fo2.getPosition(), fo1.getPosition());
              int len = (int)dist.length();
              if(len>0 && len < 250){ // Affect area...
                //Vector2d alfa = new Vector2d(fo1.getPosition());
                FysixObject foA;
                FysixObject foB;
View Full Code Here


public class FysixCollisionDetector {

  public static boolean checkCollision(FysixObject fo1, FysixObject fo2) {
    Vector2d relVel = new Vector2d();
    relVel.sub(fo1.getVelocity(), fo2.getVelocity());
    Polygon p1 = fo1.getBoundingArea();
    p1.translate((int)fo1.getPosition().x, (int)fo1.getPosition().y);
    Polygon p2 = fo2.getBoundingArea();
    p2.translate((int)fo2.getPosition().x, (int)fo2.getPosition().y);
    PolygonCollisionResult res = PolygonCollision(p1, p2, relVel);
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public SteeringBehaviourOutput runFace(Point2d position, Vector2d orientation, double angularSpeed, double maxAngularAcc, Point2d target) {
    Vector2d alignTarget = new Vector2d();
    alignTarget.sub(target, position);
    if (alignTarget.length()<this.ignoreDistance)
      return this.alignBehaviour.runAlign(orientation, angularSpeed, maxAngularAcc, orientation);
    return this.alignBehaviour.runAlign(orientation, angularSpeed, maxAngularAcc, alignTarget);
  }
 
View Full Code Here

   */
  public SteeringBehaviourOutput runSeek(Point2d position, double linearSpeed, double maxLinearAcc, Point2d target) {
    SteeringBehaviourOutput output = new SteeringBehaviourOutput();
   
    Vector2d direction = new Vector2d();
    direction.sub(target,position);
   
    direction.normalize();   
    direction.scale(maxLinearAcc);
   
    output.setLinear(direction.getX(), direction.getY());
View Full Code Here

   */
  public KinematicBehaviourOutput runSeek(Point2d position, double linearSpeed, double maxLinearSpeed, Point2d target) {
    KinematicBehaviourOutput output = new KinematicBehaviourOutput();
   
    Vector2d direction = new Vector2d();
    direction.sub(target,position);
   
    direction.normalize();   
    direction.scale(maxLinearSpeed);
   
    output.setLinear(direction.getX(), direction.getY());
View Full Code Here

    Vector2d aVector = new Vector2d(-lineVector.y, lineVector.x);
   
    Vector2d newAtomVector = new Vector2d(atomCoords);
   
    // Translate so line goes through origin
    newAtomVector.sub(start);
   
    // Magic formula
    Vector2d refVect = new Vector2d(aVector);
    refVect.scale(2*aVector.dot(newAtomVector)/aVector.dot(aVector));
    newAtomVector.sub(refVect);
 
View Full Code Here

            forceFromHook_.add(gravityForce);
            // also add a restoring force which is proportional to the distnace from the attachpoint on the sling
            // if we have not yet been released.

            Vector2d restoreForce = sling_.getProjectileAttachPoint();
            restoreForce.sub(projectile_.getPosition());
            restoreForce.scale(100.0);
            forceFromHook_.add(restoreForce);
            projectile_.setForce(forceFromHook_, timeStep);
        else {
            Vector2d gravityForce = new Vector2d(GRAVITY_VEC);
View Full Code Here

            // so that it can be scaled back to screen space...
        PathBuilder pb = new PathBuilder();
        pb.color( jcpModel.getHoverOverColor() );

        Vector2d vec = new Vector2d();
        vec.sub( p2, p1 );

        Vector2d per = GeometryTools.calculatePerpendicularUnitVector( p1, p2 );
        per.scale( radius );
        Vector2d per2 = new Vector2d();
        per2.scale( -1 ,per);
View Full Code Here

      if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) {
        IAtomContainer undoRedoContainer = chemModel.getBuilder()
            .newInstance(IAtomContainer.class);
        undoRedoContainer.addAtom(atom);
        Vector2d end = new Vector2d();
        end.sub(worldCoords, atom.getPoint2d());
        IUndoRedoable undoredo = getUndoRedoFactory().getMoveAtomEdit(
            undoRedoContainer, end, "Move atom");
        getUndoRedoHandler().postEdit(undoredo);
      }
      moveToWithoutUndo(atom, worldCoords);
View Full Code Here

  public void moveToWithoutUndo(IBond bond, Point2d point) {
    if (bond != null) {
      Point2d center = bond.get2DCenter();
      for (IAtom atom : bond.atoms()) {
        Vector2d offset = new Vector2d();
        offset.sub(atom.getPoint2d(), center);
        Point2d result = new Point2d();
        result.add(point, offset);

        atom.setPoint2d(result);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.