Examples of Vector2D


Examples of Hexel.math.Vector2d

    return this.thingTools.collidesWater(v, zeroOffset, this.fixOffsetTmps);
  }

  public boolean isUnderwater(double x, double y, double z) {
    Vector3i tmp3i = new Vector3i();
    Vector2d tmp2d = new Vector2d();
    return this.thingTools.collidesWater(x, y, z, tmp2d, tmp3i);
  }
View Full Code Here

Examples of cc.sketchchair.triangulate.Vector2D

        Vec2D v = this.getPos(t);

        if (t != 0) {
          SketchPoint nodeBetween = this.getNodeBetween(t - step, t);
          if (nodeBetween != null) {
            loop.add(new Vector2D(nodeBetween.x, nodeBetween.y));
          }

        }

        if (prevVec == null || v.x != prevVec.x && v.y != prevVec.y
            && v != null) {
          prevVec = v;
          loop.add(new Vector2D(v.x, v.y));
        }

      }

    } else {
      for (int i = 1; i < this.l.size(); i++) {
        SketchPoint v = this.l.get(i);
        if (prevVec == null || v.x != prevVec.x && v.y != prevVec.y) {
          prevVec = v;
          loop.add(new Vector2D(v.x, v.y));
        }

      }
    }
View Full Code Here

Examples of com.aqpproject.tools.Vector2D

    public IAController(String playerName) {
        m_playerName = playerName;
        m_fireTime = -1;
        m_lastMovingTime = Singleton.getWorldModel().getTime();
        m_lastResetTime = 0;
        m_lastValidPosition = new Vector2D();
    }
View Full Code Here

Examples of com.sk89q.worldedit.Vector2D

        if (x == null || z == null) {
            return null;
        }

        return new Vector2D(x, z);
    }
View Full Code Here

Examples of com.vividsolutions.jts.math.Vector2D

  public void addSide(int level, Coordinate p0, Coordinate p1) {
    if (level == 0)
      addSegment(p0, p1);
    else {
      Vector2D base = Vector2D.create(p0, p1);
      Coordinate midPt = base.multiply(0.5).translate(p0);
     
      Vector2D heightVec = base.multiply(THIRD_HEIGHT);
      Vector2D offsetVec = heightVec.rotateByQuarterCircle(1);
      Coordinate offsetPt = offsetVec.translate(midPt);
     
      int n2 = level - 1;
      Coordinate thirdPt = base.multiply(ONE_THIRD).translate(p0);
      Coordinate twoThirdPt = base.multiply(TWO_THIRDS).translate(p0);
     
View Full Code Here

Examples of crazypants.vecmath.Vector2d

    }

    if(selectedCoord != null) {
     
      Vector3d blockCenter = new Vector3d(selectedCoord.x + 0.5, selectedCoord.y + 0.5, selectedCoord.z + 0.5);
      Vector2d blockCenterPixel = currentView.getScreenPoint(blockCenter);           
     
      Vector2d screenMidPixel = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
      screenMidPixel.scale(0.5);

     
      double pixDist = blockCenterPixel.distance(screenMidPixel);
      double rat = pixDist / Minecraft.getMinecraft().displayHeight;
      if(rat != rat) {
View Full Code Here

Examples of def_classes.Vector2D

  }

  public void updateMovement() {
    double speedX = -xRadius*(Math.sin(cycleDegree*Math.PI/180))*cycleStep*Math.PI/180;
    double speedY = yRadius*(Math.cos(cycleDegree*Math.PI/180))*cycleStep*Math.PI/180;
    Vector2D newVelocity = new Vector2D(speedX,speedY);
    //velocity.setX(speedX);
    //velocity.setY(speedY);
    setVelocity(newVelocity);
    cycleDegree += cycleStep;
    setMovement(getVelocity());
View Full Code Here

Examples of eas.math.geometry.Vector2D

     */
    @Override
    public List<SingleParameter> getParameters() {
        ArrayList<SingleParameter> arr = new ArrayList<SingleParameter>(7);
        ArrayListVec2D av = new ArrayListVec2D();
        av.add(new Vector2D(29.12, 212.2));
        av.add(new Vector2D(1.12, 12.2));
        av.add(new Vector2D(9.12, .2));

        ArrayListDouble av2 = new ArrayListDouble();
        av2.add(1.1);
        av2.add(2.2);
        av2.add(3.3);
View Full Code Here

Examples of edu.stanford.hci.flowmap.cluster.Vector2D

                count++;
            }

            avgX /= count;
            avgY /= count;
            Vector2D gpVec = new Vector2D(n1Pt, new Point2D.Double(avgX, avgY));
            Point2D gpVecNorm = gpVec.getNormalized();
            gpVecNorm.setLocation(-1 * gpVecNorm.getX(), -1 * gpVecNorm.getY());
            grandParent = new Point2D.Double(n1Pt.getX() + 10
                    * gpVecNorm.getX(), n1Pt.getY() + 10 * gpVecNorm.getY());
           

        } else {
            //System.out.println("n2 is not null");
            grandParent = n1.getPrevControlPoint();
            //System.out.println("Prev Control Point for " +
            // ((FlowNode)n1.getEntity()).toStringId() + " has prev control
            // point: " + grandParent);
        }
        //System.out.println("grandparent: " + grandParent);

        // 2. the parent catmull-rom point is n1, since we want it to
        // go through this point
        parent = n1.getLocation();
       
        Point2D shiftPoint = null;
        // additive edge code
        // only shift edges if we are not at the root
        // relies on the fact that there only 2 edges per node
        if (m_additiveEdges && (n1.getRoutingParent() != null)) {

            n2 = n1.getRoutingParent(); //redundant, but who cares
           
            // get the other edge that starts from n1
            Edge otherEdgeItem = null;
            //System.out.println("n1.getOutEdges().size() " + n1.getOutEdges().size());
            for (Edge other: n1.getOutEdges()) {
                if ((otherEdgeItem = other) != edge) break;
            }
            assert(otherEdgeItem != null);
           
//          find the parent edge from n2 to n1
            Edge parentEdgeItem = null;
            for (Edge parent: n2.getOutEdges()) {
                parentEdgeItem = parent;
                if (parentEdgeItem.isIncident(n1) && (parentEdgeItem.isIncident(n2))) {
                    break;               
                }
            }
            assert(parentEdgeItem != null);
           
            Node item1;
            Node item2;
            // get vectors for both edges
            item1 = edge.getFirstNode();
            item2 = edge.getSecondNode();
            Vector2D thisEdgeVec = new Vector2D(item1.getLocation(), item2.getLocation());
           
            item1 = otherEdgeItem.getFirstNode();
            item2 = otherEdgeItem.getSecondNode();
            Vector2D otherEdgeVec = new Vector2D(item1.getLocation(), item2.getLocation());
           
            // now do the cross product of thisEdgeVec
           
//            do not use Vector3d but own implementation that gets rid of this dependency
//            Vector3d thisEdgeVector = new Vector3d(thisEdgeVec.getNormalized().getX(), -1*thisEdgeVec.getNormalized().getY(), 0);
//            Vector3d otherEdgeVector = new Vector3d(otherEdgeVec.getNormalized().getX(), -1*otherEdgeVec.getNormalized().getY(), 0);
//           
//            Vector3d result = new Vector3d();
//
//            result.cross(thisEdgeVector, otherEdgeVector);
            double[] cross = computeCrossProduct(thisEdgeVec.getNormalized().getX(), -1*thisEdgeVec.getNormalized().getY(),
                    otherEdgeVec.getNormalized().getX(), -1*otherEdgeVec.getNormalized().getY());
            //System.out.println("edges: " + parentEdgeItem + ", " + edgeItem + " , " + otherEdgeItem);
            //System.out.println(result);
           
            // compute the perpendicular vector, the direction to shift
            // we will get a vector that points to the right
            Vector2D grandToParent = new Vector2D(grandParent, parent);
            Point2D shiftDir = new Point2D.Double(-grandToParent.getNormalized().getY(),
                    -grandToParent.getNormalized().getX());
           
//            if (result.z < 0) {
            if (cross[2] < 0 ) {
            // if z > 0 then we know that thisEdge is to the right of otherEdge
            // so we push this in the direction of shiftDir

            // else we know that thisEdge is to the left of otherEdge
            // so we push this up, or in the negative direction of shiftDir
                shiftDir.setLocation(shiftDir.getX()*-1, shiftDir.getY()*-1);
            }
           
            double parentWidth = scale.getDisplayWidth(parentEdgeItem.getWeight());
            double otherWidth = scale.getDisplayWidth(otherEdgeItem.getWeight());
            parentWidth = Math.round(parentWidth);
            otherWidth = Math.round(otherWidth);
    /*
            System.out.println("edges: par: " + parentEdgeItem + ", edge:" + edgeItem + " , other:" + otherEdgeItem);
            System.out.println("parentActual: " + parentEdgeItem.getWeight(currFlowType) + " dispActual: " + edgeItem.getWeight(currFlowType) + " otherActual: " + otherEdgeItem.getWeight(currFlowType));
            System.out.println("parentWidth: " + parentWidth + " dispWidth: " + displayWidth + " otherWidth: " + otherWidth);
        */ 
            assert(parentWidth >= displayWidth);
           
            // compute the distance to shift this edge. It should be:
            // parentDisplayWidth/2 - displayWidth/2
            double shiftDist = (parentWidth/2) - (displayWidth/2);
           
            shiftPoint = new Point2D.Double(shiftDist*shiftDir.getX(),
                    -1*shiftDist*shiftDir.getY());

        }

        // 6. Set the child catmull-rom pont to be e1.to
        child = edge.getSecondNode().getLocation();

        // 7. Compute the grand child catmull-rom point.
        // It is either the position of the heavier child,
        // or if there are no more child nodes, it is in a straight
        // line with parent and child, just further out
        Collection<Edge> grandChildEdges = edge.getSecondNode().getOutEdges();
        if (grandChildEdges.size() != 0) {
            double gcWeight, gcX, gcY;
            gcX = gcY = gcWeight = -1;
           
            // find the heaviest child
            for(Edge gcEdge: grandChildEdges) {
                if (gcEdge.getWeight() > gcWeight) {
                    gcWeight = gcEdge.getWeight();
                    gcX = gcEdge.getSecondNode().getLocation().getX();
                    gcY = gcEdge.getSecondNode().getLocation().getY();
                    //System.out.println("x: " + gcX + " y:" + gcY);
                }                  
            }
            assert(gcWeight != -1);
            grandChild = new Point2D.Double(gcX, gcY);
            GraphicsGems.checkNaN(grandChild);
        } else {
            /*
            System.out.println();
            System.out.println(grandParent);
            System.out.println(parent);
            System.out.println(child);
            */
            Vector2D parentToChild = new Vector2D(parent, child);
            Point2D pToCDir = parentToChild.getNormalized();
           
        //  System.out.println(pToCDir);

            Vector2D grandParentToParent = new Vector2D(grandParent, parent);
            Point2D gpToPDir = grandParentToParent.getNormalized();
            //System.out.println(gpToPDir);

            double angleBetween = parentToChild
                    .absAngleBetween(grandParentToParent);
           
            //System.out.println(edgeItem + " angleBetween is " + (180*angleBetween/Math.PI));

            // now rotate the parentToChild normalized vector by -angleBetween
            // assuming rotations are CCW

            double x = pToCDir.getX() * Math.cos(-angleBetween)
                    - pToCDir.getY() * Math.sin(-angleBetween);
            double y = pToCDir.getX() * Math.sin(-angleBetween)
                    + pToCDir.getY() * Math.cos(-angleBetween);

            //System.out.println("grandChild case 2: " + x + "," + y);
            grandChild = new Point2D.Double(child.getX() + 100 * x, child
                    .getY()
                    + 100 * y);
            GraphicsGems.checkNaN(grandChild);

        }

       

        // 8. Now that we know where all the catmull-rom objects are,
        // construct a BasicStroke object with e1's thickness
//      haha, it's not even read ...
//        BasicStroke bs = new BasicStroke((float) displayWidth,
//                BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);

        // 9. construct a CubicCurve object with the given control points
        // by passing the four points object to the BezierSpline.computeSplines
        // function
        fourPoints[0] = grandParent;
        fourPoints[1] = parent;
        fourPoints[2] = child;
        fourPoints[3] = grandChild;

        Shape shape = edge.getShape();
        CubicCurve2D myCurve;
        if (shape == null) {
            myCurve = new CubicCurve2D.Double();
            edge.setShape(myCurve);
        } else {
            myCurve = (CubicCurve2D)shape;
        }
       
        BezierSpline.computeOneSpline(grandParent, parent, child, grandChild, myCurve);

        // 11. Now do some tweaking of the control points to ensure continuity.
        // need to tweak the first control point to be collinear with the parent
        // and the grandparent and have the same distance as the
        // parent-grandparent
        double parentGrandDist = grandParent.distance(parent);

        Vector2D grandToParent = new Vector2D(grandParent, parent);
        //System.out.println(grandToParent);
        //now take the grandToParent vector, scale by parentGrandDistance, add
        // it to the parent vector
       
          Point2D collinShift = new Point2D.Double(parentGrandDist
                * grandToParent.getNormalized().getX() + parent.getX(),
                parentGrandDist * grandToParent.getNormalized().getY()
                        + parent.getY());
        //System.out.println("before: " + myCurve.getP1() + ", "
        // +myCurve.getCtrlP1() + ", " + myCurve.getCtrlP2() + ", " +
        // myCurve.getP2() );
        myCurve.setCurve(myCurve.getP1(), collinShift, myCurve.getCtrlP2(),
View Full Code Here

Examples of graphics.common.Vector2D

    }

    private static class Get2D implements GetVector {
        @Override
        public Vector get( double xPart, double yPart, double zPart ) {
            return new Vector2D( xPart, yPart );
        }
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.