Package javax.vecmath

Examples of javax.vecmath.Vector2d


            //System.out.println("tangentialForceAtHook="+tangentialForceAtHook);
            double slingAngleWithHorz = sling_.getAngleWithHorz();

            forceFromHook_.set(-cos(slingAngleWithHorz), sin(slingAngleWithHorz))//sin(PI - angle), -cos(PI + angle));
            forceFromHook_.scale( tangentialForceAtHook * sin(slingAngle));
            Vector2d gravityForce = new Vector2d(GRAVITY_VEC);
            gravityForce.scale(projectile_.getMass());
            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);
            gravityForce.scale(projectile_.getMass());
            projectile_.setForce(gravityForce, timeStep);
        }


        // at the time when it is released, the only force acting on it will be gravity.
View Full Code Here


    /**
     * @return The equivalent Vector2d
     */
    public Vector2d toVector2d() {
        return new Vector2d(x, y);
    }
View Full Code Here

            // the element size has to be scaled to model space
            // 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);

        Vector2d v1= new Vector2d(vec);
        Vector2d v2= new Vector2d();

        v1.normalize();
        v1.scale( radius );
        v2.scale( -1, v1 );

        Point2d f1 = new Point2d();
        Point2d f2 = new Point2d();
        Point2d f3 = new Point2d();
        Point2d s1 = new Point2d();
View Full Code Here

       
    }
   
    public void visit(WedgeLineElement wedge) {
        // make the vector normal to the wedge axis
        Vector2d normal =
            new Vector2d(wedge.firstPointY - wedge.secondPointY, wedge.secondPointX - wedge.firstPointX);
        normal.normalize();
        normal.scale(rendererModel.getWedgeWidth() / rendererModel.getScale())
       
        // make the triangle corners
        Point2d vertexA = new Point2d(wedge.firstPointX, wedge.firstPointY);
        Point2d vertexB = new Point2d(wedge.secondPointX, wedge.secondPointY);
        Point2d vertexC = new Point2d(vertexB);
View Full Code Here

                        Math.abs(p2[0] - p1[0]), Math.abs(p2[1] - p1[1])));
    if (!shorten_line (p1, p2)) return;
    double w1[] = invTransformPoint (p1[0], p1[1]);
    double w2[] = invTransformPoint (p2[0], p2[1]);
        // make the vector normal to the wedge axis
        Vector2d normal =
            new Vector2d(w1[1] - w2[1], w2[0] - w1[0]);
        normal.normalize();
        normal.scale(rendererModel.getWedgeWidth() / rendererModel.getScale())
       
        // make the triangle corners
        Point2d vertexA = new Point2d(w1[0], w1[1]);
        Point2d vertexB = new Point2d(w2[0], w2[1]);
        Point2d vertexC = new Point2d(vertexB);
View Full Code Here

    List<IAtom> connectedAtoms = atomCon.getConnectedAtomsList(atom);

    if (connectedAtoms.size() == 0) {
      Point2d newAtomPoint = new Point2d(atom.getPoint2d());
      double angle = Math.toRadians(-30);
      Vector2d vec1 = new Vector2d(Math.cos(angle), Math.sin(angle));
      vec1.scale(bondLength);
      newAtomPoint.add(vec1);
      newAtom.setPoint2d(newAtomPoint);
    } else if (connectedAtoms.size() == 1) {
      IAtomContainer ac = atomCon.getBuilder().newInstance(IAtomContainer.class);
      ac.addAtom(atom);
      ac.addAtom(newAtom);
      Point2d distanceMeasure = new Point2d(0, 0); // XXX not sure about
      // this?
      IAtom connectedAtom = connectedAtoms.get(0);
      Vector2d v = atomPlacer.getNextBondVector(atom, connectedAtom,
          distanceMeasure, true);
      atomPlacer.placeLinearChain(ac, v, bondLength);
    } else {
      IAtomContainer placedAtoms = atomCon.getBuilder().newInstance(IAtomContainer.class);
      for (IAtom conAtom : connectedAtoms)
View Full Code Here

    if (atom != null) {
      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

  // OK
  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

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

                        }
                        Rectangle2D shiftedBounds =
                            GeometryTools.shiftContainer(
                                    container, bounds, usedBounds, gap*2);
                        double yshift=centerY - bounds.getCenterY();
                        Vector2d shift = new Vector2d(0.0, yshift);
                        GeometryTools.translate2D(container, shift);
                        usedBounds = usedBounds.createUnion(shiftedBounds);
                    } else {
                        usedBounds = bounds;
                        centerY = bounds.getCenterY();
                    }
                }
                //we shift the products an extra bit to make a larget gap between products and reactants
                for(IAtomContainer container : reaction.getProducts().atomContainers()){
                    Vector2d shift = new Vector2d(gap*2, 0.0);
                    GeometryTools.translate2D(container, shift);
                }
            }
        }
        //TODO overlaps of molecules in molecule set and reactions (ok, not too common, but still...)
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2d

Copyright © 2018 www.massapicom. 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.