Java 类javafx.geometry.Point3D 实例源码

项目:javafx-3d-surface-chart    文件:Mesh3DChartPanel.java   
private void calculateAndRotatoNodes(List<Node> nodes, double alp, double bet, double gam) {
    double A11 = Math.cos(alp) * Math.cos(gam);
    double A12 = Math.cos(bet) * Math.sin(alp) + Math.cos(alp) * Math.sin(bet) * Math.sin(gam);
    double A13 = Math.sin(alp) * Math.sin(bet) - Math.cos(alp) * Math.cos(bet) * Math.sin(gam);
    double A21 = -Math.cos(gam) * Math.sin(alp);
    double A22 = Math.cos(alp) * Math.cos(bet) - Math.sin(alp) * Math.sin(bet) * Math.sin(gam);
    double A23 = Math.cos(alp) * Math.sin(bet) + Math.cos(bet) * Math.sin(alp) * Math.sin(gam);
    double A31 = Math.sin(gam);
    double A32 = -Math.cos(gam) * Math.sin(bet);
    double A33 = Math.cos(bet) * Math.cos(gam);

    double d = Math.acos((A11 + A22 + A33 - 1d) / 2d);
    if (!ObjectUtils.equalsDoublePrecision(d, 0.0)) {
        double den = 2d * Math.sin(d);
        Point3D p = new Point3D((A32 - A23) / den, (A13 - A31) / den, (A21 - A12) / den);
        for (Node node : nodes) {
            node.setRotationAxis(p);
            node.setRotate(Math.toDegrees(d));
        }
    }
}
项目:Gargoyle    文件:GoogleTrendChartEvent.java   
/**
 * @param source
 * @param target
 * @param eventType
 * @param x
 * @param y
 * @param screenX
 * @param screenY
 * @param pickResult
 * @param clickCount
 * @param contents
 */
public GoogleTrendChartEvent(Object source, EventTarget target, EventType<? extends GoogleTrendChartEvent> eventType, double x,
        double y, double screenX, double screenY, PickResult pickResult, int clickCount, List<Node> contents) {
    super(source, target, eventType);
    this.x = x;
    this.y = y;
    this.screenX = screenX;
    this.screenY = screenY;
    this.sceneX = x;
    this.sceneY = y;
    this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
    final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
    this.x = p.getX();
    this.y = p.getY();
    this.z = p.getZ();
    this.clickCount = clickCount;
    this.contents = contents;
}
项目:Gargoyle    文件:DockEvent.java   
/**
 * Constructs new DockEvent event..
 * 
 * @param source the source of the event. Can be null.
 * @param target the target of the event. Can be null.
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 * @param contents The contents being dragged during this event.
 */
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
    double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
  super(source, target, eventType);
  this.x = x;
  this.y = y;
  this.screenX = screenX;
  this.screenY = screenY;
  this.sceneX = x;
  this.sceneY = y;
  this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
  final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
  this.x = p.getX();
  this.y = p.getY();
  this.z = p.getZ();
  this.contents = contents;
}
项目:DUTS3-CPOA-ProjetTarot    文件:GameView.java   
/**
 * This method is called by @update if the update type is @SPREAD_CARDS
 * It spreads the card of a group on the table
 * @since v0.7.1
 * @param   cardUpdate     the cardUpdate object.
 */
private void spreadAllCards(CardUpdate cardUpdate) throws NullViewCardException {
    int nbCardInRow = (int)(( CARPET_SIZE - MARGIN_TABLE*2)/(ViewCard.getWidth()+MARGIN_CARDS));
    int i = 0;
    int j = 0;
    for(Card card : cardUpdate.getCardGroup()) {
        Point3D position = new Point3D(MARGIN_TABLE + i*(MARGIN_CARDS+ViewCard.getWidth()), MARGIN_TABLE
                + j*(MARGIN_CARDS+ViewCard.getHeight()), -ViewCard.getDepth());
        CardUpdate newCardUpdate = new CardUpdate(CardUpdateType.MOVE_CARD_BETWEEN_GROUPS, card, null);
        cardUpdate.addSubUpdate(newCardUpdate);
        changeCardGroup(newCardUpdate, position, 1000);
        i++;
        if (i>nbCardInRow-1)
        {
            i=0;
            j++;
        }
    }
    cardUpdate.setAnimationFinished();
}
项目:DUTS3-CPOA-ProjetTarot    文件:ViewCamera.java   
/**
 * Moves the camera
 * @since v0.2
 *
 * @param position the new camera position
 * @param rotation the new camera rotation
 * @param transitionTime the transition length to new camera position and rotation
 */
public void moveCamera(Point3D position, double rotation, int transitionTime)
{
    if (getTranslateX() != position.getX() || getTranslateY() != position.getY() || getTranslateZ() != position.getZ() || rotation != getRotate())
    {
        if (transitionTime < 1)
        {
            transitionTime = 1;
        }
        Timeline timeline = new Timeline();
        timeline.getKeyFrames().addAll(
                new KeyFrame(new Duration(transitionTime), new KeyValue(translateXProperty(), position.getX())),
                new KeyFrame(new Duration(transitionTime), new KeyValue(translateYProperty(), position.getY())),
                new KeyFrame(new Duration(transitionTime), new KeyValue(translateZProperty(), position.getZ())),
                new KeyFrame(new Duration(transitionTime), new KeyValue(rotateProperty(), rotation))
        );
        timeline.play();
    }
}
项目:openjfx-8u-dev-tests    文件:MeshPickingTests.java   
/**
     * Test Check that Intersected Points is correct in not extremum points.
     */
    @Test(timeout = 20000)
    public void valuesTest() {
        eps = 0.1;
        Rectangle rect = getAppRectangle();
        int leftX = getLeftX() + rect.x;
        int topY = getTopY() + rect.y;
        int delta = getDelta();
        int iterations = getIterations();

        final double miniDelta = ((double) delta) / ((double) iterations);
        Point3D points[] = new Point3D[iterations * 4];
        fillPathPointsArray(leftX, topY, miniDelta, 0D, points, 0, iterations);
        fillPathPointsArray(leftX + delta, topY, 0D, miniDelta, points, iterations, iterations);
        fillPathPointsArray(leftX + delta, topY + delta, -miniDelta, 0D, points, 2 * iterations, iterations);
        fillPathPointsArray(leftX, topY + delta, 0D, -miniDelta, points, 3 * iterations, iterations);
        for (int i = 0; i < 4 * iterations; i++) {
            double z = points[i].getZ();
            double expected = Math.sin(Math.PI / 2 + Math.PI / ((double) iterations) * (double) i);
//            System.out.println(expected + "  " + z);
            Assert.assertTrue("Expected " + expected + ", but was " + z, Math.abs(z - expected) < eps);
        }
    }
项目:openjfx-8u-dev-tests    文件:AnimationTransitionApp.java   
@Override
public Node drawNode() {
    currentTestNode = this;
    RotateTransition transition = new RotateTransition();
    Pane p = pre(transition);

    transition.setDuration(Duration.millis(typicalDuration));
    transition.setNode(circle);

    circle.setRotate(dFrom);
    transition.setFromAngle(dFrom);
    transition.setByAngle(dBy);

    transition.setCycleCount(1);
    transition.setAutoReverse(true);

    Point3D p3d = new Point3D(0,0,100);
    transition.setAxis(p3d);
    if (!p3d.equals(transition.getAxis()))  {
        reportGetterFailure("TransitionRotate.getAxis()");
    }

    return p;
}
项目:gluon-samples    文件:Utils.java   
public static String getRightRotation(Point3D p, String selFaces){
        double radius = p.magnitude();
        double angle = Math.atan2(p.getY(), p.getX());
        String face="";
        if (radius >= RAD_MINIMUM && selFaces.contains("-") && selFaces.split("-").length == 2) {
            String[] faces = selFaces.split("-");
            // select rotation if p.getX>p.getY
            if (-Math.PI / 4d <= angle && angle < Math.PI / 4d ){ // X
                face = faces[0];
            } else if (Math.PI / 4d <= angle && angle < 3d * Math.PI / 4d) { // Y
                face = faces[1];
            } else if ((3d * Math.PI / 4d <= angle && angle <= Math.PI) || 
                      (-Math.PI <= angle && angle < -3d * Math.PI / 4d)) { // -X
                face = reverseRotation(faces[0]);
            } else { //-Y
                face = reverseRotation(faces[1]);
            }
//            System.out.println("face: "+face);
        } else if (!face.isEmpty() && radius < RAD_MINIMUM) { // reset previous face
            face = "";
        }
        return face;
    }
项目:DockFX    文件:DockEvent.java   
/**
 * Constructs new DockEvent event..
 * 
 * @param source the source of the event. Can be null.
 * @param target the target of the event. Can be null.
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 * @param contents The contents being dragged during this event.
 */
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
    double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
  super(source, target, eventType);
  this.x = x;
  this.y = y;
  this.screenX = screenX;
  this.screenY = screenY;
  this.sceneX = x;
  this.sceneY = y;
  this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
  final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
  this.x = p.getX();
  this.y = p.getY();
  this.z = p.getZ();
  this.contents = contents;
}
项目:fr.xs.jtk    文件:Quaternion.java   
protected void matrixRotateNode0(Node n, double alf, double bet, double gam){
    double A11=Math.cos(alf)*Math.cos(gam);
    double A12=Math.cos(bet)*Math.sin(alf)+Math.cos(alf)*Math.sin(bet)*Math.sin(gam);
    double A13=Math.sin(alf)*Math.sin(bet)-Math.cos(alf)*Math.cos(bet)*Math.sin(gam);
    double A21=-Math.cos(gam)*Math.sin(alf);
    double A22=Math.cos(alf)*Math.cos(bet)-Math.sin(alf)*Math.sin(bet)*Math.sin(gam);
    double A23=Math.cos(alf)*Math.sin(bet)+Math.cos(bet)*Math.sin(alf)*Math.sin(gam);
    double A31=Math.sin(gam);
    double A32=-Math.cos(gam)*Math.sin(bet);
    double A33=Math.cos(bet)*Math.cos(gam);

    double d = Math.acos((A11+A22+A33-1d)/2d);
    if(d!=0d){
        double den=2d*Math.sin(d);
        Point3D p= new Point3D((A32-A23)/den,(A13-A31)/den,(A21-A12)/den);
        n.setRotationAxis(p);
        n.setRotate(Math.toDegrees(d));                    
    }
}
项目:COrnLathe    文件:OffRosettePoint.java   
/**
 * Make a 3D Line for this OffRosettePoint.
 *
 * @return 3D Line
 */
Line3D make3DLine() {
  Line3D line = new Line3D();

  Vector2d offset = offsetFromParent();
  double x0 = offset.x;     // point where cutter contacts the surface
  double y0 = getY();     // (y should always be zero)      
  double z0 = offset.y;

  for (int i = 0; i < (NUM_3D_PTS + 1); i++) {
    double angDeg = (double) i * 360.0 / (double) NUM_3D_PTS;   // in degrees
    double angRad = Math.toRadians(angDeg);
    Vector2d xz = rosetteMove(angDeg, x0, z0);   // xz location due to rosette motion
    double r = Math.hypot(xz.x, y0);        // cylindrical radius  NOTE: y should always be 0.0
    if (cutter.getLocation().isBack()) {    // if in back, add 180 degrees rotation
      angRad += Math.PI;
    }
    line.add(new Point3D(r * Math.cos(-angRad), r * Math.sin(-angRad), xz.y));
  }
  return line;
}
项目:COrnLathe    文件:Surface.java   
/**
 * Make a clean new surface from the outline.
 *
 * @return array of Point3D[][]
 */
public synchronized Point3D[][] makeCleanSurface() {
  Point2D.Double[] curvePts;
  if (inOut) {
    curvePts = outline.getInsideCurve().getPoints();
  } else {
    curvePts = outline.getOutsideCurve().getPoints();
  }
  Point3D[][] newPts = new Point3D[curvePts.length][DEFAULT_SECTORS];
  for (int i = 0; i < curvePts.length; i++) {
    Point2D.Double pt = curvePts[i];
    for (int j = 0; j < DEFAULT_SECTORS; j++) {
      double angleRad = -TWOPI * (double) j / DEFAULT_SECTORS;    // minus to match rotation of lathe
      // convert 2D outline point to a point in 3D lathe space
      // use abs(x) in case of -x so that surface always starts the right place
      newPts[i][j] = new Point3D(
          Math.abs(pt.x) * Math.cos(angleRad),
          Math.abs(pt.x) * Math.sin(angleRad),
          pt.y);
    }
  }
  return newPts;
}
项目:COrnLathe    文件:SpiralLine.java   
/**
 * Make an array of additional twist in degrees made by the PatternBar from
 * the given SurfaceTwist.
 *
 * @param tw SurfaceTwist
 * @return additional twist in degrees for each point.
 */
private double[] makePatternTwist(Point3D[] tw) {
  PatternBar pb = ((LinePoint) beginPt).getPatternBar();
  double startR = beginPt.getX();
  double[] addTwist = new double[tw.length];
  double dist = 0.0;        // cummulative distance along tw
  if (scaleAmplitude) {
    addTwist[0] = degreesForD(pb.getAmplitudeAt(dist) * tw[0].getX()/startR, tw[0].getX()); // reminder: tw[].x is radius in lathe coords
  } else {
    addTwist[0] = degreesForD(pb.getAmplitudeAt(dist), tw[0].getX());   // reminder: tw[].x is radius in lathe coords
  }
  for (int i = 1; i < tw.length; i++) {
    dist += distance(tw[i - 1], tw[i]);
    if (scaleAmplitude) {
      addTwist[i] = degreesForD(pb.getAmplitudeAt(dist) * tw[i].getX()/startR, tw[i].getX());
    } else {
      addTwist[i] = degreesForD(pb.getAmplitudeAt(dist), tw[i].getX());
    }
  }
  return addTwist;
}
项目:COrnLathe    文件:SpiralCut.java   
/**
 * Get an array of numbers representing the twist at each point on the cut
 * surface reflected back to the nearest points on the cutter curve. 
 * The points are different that the points on the CutterCurve because they
 * are based on a finer resolution than the curve resolution.
 * Note: Twist starts at zero, so the twist is relative. You must add the phase of
 * the initial point to these numbers!
 *
 * @return an array of Point3d with x,y from the original pts and z=twist in
 * degrees (or null if there are no points given). Note: In lathe coordinates,
 * this is actually radius, z, c(degrees).
 */
public Point3D[] getCutterTwist() {
  // first find points on the surface (cutCurve)
  Point3D[] rzc = getSurfaceTwist();
  if (rzc == null) {
    return null;
  }
  switch (cutter.getFrame()) {
    case Fixed:
    case Drill:
    case ECF:
      return rzc;     // for Drill adn ECF the cut path is on the surface
  }

  // use a much finer resolution cutterPathCurve for smoothness
  Curve fineCut = outline.getCutterPathCurve(cutter);
  fineCut.reSample(outline.getResolution() / 10.0);

  // then look for the closest point on the fine resolution cut curve
  Point3D[] newPts = new Point3D[rzc.length];
  for (int i = 0; i < rzc.length; i++) {
    Point2D.Double near = fineCut.nearestPoint(new Point2D.Double(rzc[i].getX(), rzc[i].getY()));
    newPts[i] = new Point3D(near.x, near.y, rzc[i].getZ());
  }
  return newPts;
}
项目:COrnLathe    文件:LinePoint.java   
/**
 * Make the 3D Lines for this LinePoint. Use this instead of make3DLines().
 *
 * @param xyz list of unrotated points in x, y, z space
 */
void make3DLines(ArrayList<Point3D> xyz) {
  list3D.clear();
  String fullMask = mask;
  if (!fullMask.isEmpty()) {
    while (fullMask.length() < repeat) {
      fullMask += mask; // fill out to full length
    }
  }
  double ang = phase / repeat;
  for (int i = 0; i < repeat; i++) {
    if (mask.isEmpty() || (fullMask.charAt(i) != '0')) {
      Line3D line = new Line3D(xyz);
      line.rotate(RotMatrix.Axis.Z, ang);
      list3D.add(line);
    }
    ang -= 360.0 / (double) repeat;
  }
}
项目:javafx-3d-surface-chart    文件:StarterFrame.java   
private List<Point3D> getPointsForGauss() {
    List<Point3D> result = new ArrayList<Point3D>();
    for (double x = -3.0; x <= 3.0; x = x + 0.20) {
        for (double y = -3.0; y <= 3.0; y = y + 0.20) {
            result.add(new Point3D(x, calculatePDF(x, y), y));
        }
    }
    return result;
}
项目:javafx-3d-surface-chart    文件:MeshImageBuilder.java   
/**
 * Calculates the z value of an given 3d triangle and a 2d point, where x and y coordinates are in this triangle
 * http://math.stackexchange.com/a/851752
 */
public static double calculateZValueInTriangle(Point2D p, Point3D p0, Point3D p1, Point3D p2) {
    double divider = ((p1.getX() - p0.getX()) * (p2.getY() - p0.getY())) - ((p2.getX() - p0.getX()) * (p1.getY() - p0.getY()));
    double z = p0.getZ() + (((((p1.getX() - p0.getX()) * (p2.getZ() - p0.getZ())) - ((p2.getX() - p0.getX()) * (p1.getZ() - p0.getZ()))) / divider) * (p.getY() - p0.getY()))
            - (((((p1.getY() - p0.getY()) * (p2.getZ() - p0.getZ())) - ((p2.getY() - p0.getY()) * (p1.getZ() - p0.getZ()))) / divider) * (p.getX() - p0.getX()));
    return z;
}
项目:javafx-3d-surface-chart    文件:MeshImageBuilder.java   
/**
 * Calculates the y value of an given 3d triangle and a 2d point, where x and z coordinates are in this triangle
 */
public static double calculateYValueInTriangle(Point2D p, Point3D p0, Point3D p1, Point3D p2) {
    double divider = ((p1.getZ() - p0.getZ()) * (p2.getX() - p0.getX())) - ((p1.getX() - p0.getX()) * (p2.getZ() - p0.getZ()));
    double y = p0.getY() + (((((p1.getY() - p0.getY()) * (p2.getX() - p0.getX())) - ((p1.getX() - p0.getX()) * (p2.getY() - p0.getY()))) / divider) * (p.getY() - p0.getZ()))
            - (((((p1.getY() - p0.getY()) * (p2.getZ() - p0.getZ())) - ((p2.getY() - p0.getY()) * (p1.getZ() - p0.getZ()))) / divider) * (p.getX() - p0.getX()));
    return y;
}
项目:javafx-3d-surface-chart    文件:MeshImageBuilder.java   
/**
 * method returns true, if point p is in the triangle. Method uses barycentric coordinate system.
 * https://stackoverflow.com/questions/2049582/how-to-determine-a-point-in-a-triangle
 */
public static boolean isPointInTriangle(Point2D p, Point3D p0, Point3D p1, Point3D p2) {
    double area = 0.5 * (-p1.getZ() * p2.getX() + p0.getZ() * (-p1.getX() + p2.getX()) + p0.getX() * (p1.getZ() - p2.getZ()) + p1.getX() * p2.getZ());
    int sign = area < 0.0 ? -1 : 1;
    double s = (p0.getZ() * p2.getX() - p0.getX() * p2.getZ() + (p2.getZ() - p0.getZ()) * p.getX() + (p0.getX() - p2.getX()) * p.getY()) * sign;
    double t = (p0.getX() * p1.getZ() - p0.getZ() * p1.getX() + (p0.getZ() - p1.getZ()) * p.getX() + (p1.getX() - p0.getX()) * p.getY()) * sign;

    return s > 0.0 && t > 0.0 && (s + t) < 2.0 * area * sign;
}
项目:javafx-3d-surface-chart    文件:MeshCalculationComposite.java   
private MeshCalculationComposite(List<Point3D> dataPoints, int size) {
    this.dataPoints = dataPoints;
    this.size = size;

    for (Point3D point3d : dataPoints) {
        minX = Math.min(minX, point3d.getX());
        maxX = Math.max(maxX, point3d.getX());
        minY = Math.min(minY, point3d.getY());
        maxY = Math.max(maxY, point3d.getY());
        minZ = Math.min(minZ, point3d.getZ());
        maxZ = Math.max(maxZ, point3d.getZ());
    }
    sizeX = maxX - minX;
    sizeY = maxY - minY;
    sizeZ = maxZ - minZ;

    // normalize points according to coordinate system size
    normalizedPoints = new ArrayList<Point3D>(dataPoints.size());
    for (Point3D point : dataPoints) {
        double x = (point.getX() - minX) / sizeX * size;
        double y = (point.getY() - minY) / sizeY * size;
        double z = (point.getZ() - minZ) / sizeZ * size;
        normalizedPoints.add(new Point3D(x, y, z));
    }

    triangle3DList = new ArrayList<Triangle3D>(dataPoints.size() / 2);
}
项目:Gargoyle    文件:Drag3DObject.java   
public Vec3d localToScene(Vec3d pt, Vec3d result) {
    Point3D res = camera.localToParentTransformProperty().get().transform(pt.x, pt.y, pt.z);
    if (camera.getParent() != null) {
        res = camera.getParent().localToSceneTransformProperty().get().transform(res);
    }
    result.set(res.getX(), res.getY(), res.getZ());
    return result;
}
项目:openjfx-8u-dev-tests    文件:ShapesPickingTests.java   
private void centerTestCase() {
    Point3D expected = new Point3D(0, 0, -1.0);
    Rectangle rect = getAppRectangle();
    PickResult pr = click(new Point(rect.x + rect.width / 2 - 1, rect.y + rect.height / 2 - 1));
    if (!isEqualsPoints(expected, pr.getIntersectedPoint())) {
        Assert.fail("expected " + expected + "but was " + pr.getIntersectedPoint());
    }
}
项目:openjfx-8u-dev-tests    文件:PickingTestOverall.java   
public static boolean isEqualsPoints(Point3D pt1, Point3D pt2) {
    if (Math.abs(pt1.getX() - pt2.getX()) > eps
            || Math.abs(pt1.getY() - pt2.getY()) > eps
            || Math.abs(pt1.getZ() - pt2.getZ()) > eps) {
        return false;
    }
    return true;
}
项目:openjfx-8u-dev-tests    文件:MeshPickingTests.java   
private void fillPathPointsArray(int startX, int startY, double dx, double dy, Point3D points[], int start, int iterations) {
    for (int i = 0; i < iterations; i++) {
        Point clickPoint = new Point(startX + (i * dx), startY + (i * dy));
        PickResult pr = click(clickPoint);
        points[start + i] = pr.getIntersectedPoint();
    }
}
项目:openjfx-8u-dev-tests    文件:CameraIsolateTests.java   
protected void setRotationAxis(final Point3D pd) {
    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            getCameraIsolateTestingFace().getCamera().setRotationAxis(pd);
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:SubSceneBasicPropsTest.java   
private void setRotationAxis(final Point3D p3d){
    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            application.setRotationAxis(p3d);
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:gluon-samples    文件:Utils.java   
private static Point3D getMeshNormal(MeshView mesh){
    TriangleMesh tm = (TriangleMesh) mesh.getMesh();
    float[] fPoints = new float[tm.getPoints().size()];
    tm.getPoints().toArray(fPoints);
    Point3D BA = new Point3D(fPoints[3] - fPoints[0], fPoints[4] - fPoints[1], fPoints[5] - fPoints[2]);
    Point3D CA = new Point3D(fPoints[6] - fPoints[0], fPoints[7] - fPoints[1], fPoints[8] - fPoints[2]);
    Point3D normal = BA.crossProduct(CA);
    Affine a = new Affine(mesh.getTransforms().get(0));
    return a.transform(normal.normalize());
}
项目:COrnLathe    文件:LinuxCNCConnection.java   
/**
 * Get the relative actual position of LinuxCNC.
 *
 * @return XZC are in x,y,z respectively
 */
public Point3D getPosition() {
  if (!connected) {
    return Point3D.ZERO;    // return 0,0,0 if no connection
  }
  String str = sendCommand("get rel_act_pos");
  String[] strs = str.split(" ");
  double x = Double.parseDouble(strs[1]);
  double z = Double.parseDouble(strs[3]);
  double c = Double.parseDouble(strs[6]);
  return new Point3D(x, z, c);
}
项目:eavp    文件:FPSCameraController.java   
@Override
public void pitchCamera(double radians) {

    // Get the x direction for the camera's current heading
    Transform worldTransform = xform.getLocalToSceneTransform();
    double xx = worldTransform.getMxx();
    double xy = worldTransform.getMxy();
    double xz = worldTransform.getMxz();
    Point3D xDir = new Point3D(xx, xy, xz).normalize();

    // Create a new rotation along that axis and apply it to the camera
    Rotate rotation = new Rotate(radians * 180 / Math.PI, xDir);
    affine.append(rotation);
}
项目:eavp    文件:FPSCameraController.java   
@Override
public void strafeCamera(double distance) {

    Transform worldTransform = xform.getLocalToSceneTransform();

    double xx = worldTransform.getMxx();
    double xy = worldTransform.getMxy();
    double xz = worldTransform.getMxz();
    Point3D xDir = new Point3D(xx, xy, xz).normalize();

    Point3D moveVec = xDir.multiply(distance);
    affine.appendTranslation(moveVec.getX(), moveVec.getY(),
            moveVec.getZ());
}
项目:eavp    文件:FPSCameraController.java   
@Override
public void thrustCamera(double distance) {

    Transform worldTransform = xform.getLocalToSceneTransform();
    double zx = worldTransform.getMzx();
    double zy = worldTransform.getMzy();
    double zz = worldTransform.getMzz();

    Point3D zDir = new Point3D(zx, zy, zz).normalize();

    Point3D moveVec = zDir.multiply(distance);
    affine.appendTranslation(moveVec.getX(), moveVec.getY(),
            moveVec.getZ());
}
项目:eavp    文件:FPSCameraController.java   
@Override
public void yawCamera(double radians) {

    // Get the y direction of the camera's current heading
    Transform worldTransform = xform.getLocalToSceneTransform();
    double yx = worldTransform.getMyx();
    double yy = worldTransform.getMyy();
    double yz = worldTransform.getMyz();
    Point3D yDir = new Point3D(yx, yy, yz).normalize();

    // Create a new rotation along that axis and apply it to the camera
    Rotate rotation = new Rotate(radians * 180 / Math.PI, yDir);
    affine.append(rotation);
}
项目:COrnLathe    文件:SpiralUNIFORMD.java   
/**
 * This is where the main calculation is done. Each point is calculated then
 * stuffed into twistPts[].
 *
 * Note: the first point should be set to pts[0].x, pts[0].y, 0.0
 *
 * @param pts Points representing the outline of the portion of a shape
 * @param twist total twist in degrees
 * @param amp optional amplitude parameter (not used by all spirals)
 */
@Override
public void calculate(Double[] pts, double twist, double amp) {
  double tot = 0.0;
  for (int i = 1; i < pts.length; i++) {        // find the total length
    tot += pts[i].distance(pts[i - 1]);
  }

  twistPts[0] = new Point3D(pts[0].x, pts[0].y, 0.0);   // first point is 0.0
  double cum = 0.0;     // the cumulative length
  for (int i = 1; i < twistPts.length; i++) {
    cum += pts[i].distance(pts[i - 1]);
    twistPts[i] = new Point3D(pts[i].x, pts[i].y, twist * cum / tot);
  }
}
项目:fr.xs.jtk    文件:Ray.java   
/**
 * Projects the Ray from new <code>origin</code> along <code>direction</code> by <code>distance</code>
 * @param orig the new origin point
 * @param dir the new direction of travel
 * @param dist distance to project ray
 * @return sets origin and returns projected position
 */
public Point3D setProject(Point3D orig, Point3D dir, double dist){
    setOrigin(orig);
    setDirection(dir);
    setPosition(getOrigin().add((getDirection().normalize().multiply(dist))));

    return getPosition();
}
项目:COrnLathe    文件:SpiralSIN4.java   
/**
 * This is where the main calculation is done. Each point is calculated then
 * stuffed into twistPts[].
 *
 * Note: the first point should be set to pts[0].x, pts[0].y, 0.0
 *
 * @param pts Points representing the outline of the portion of a shape
 * @param twist total twist in degrees
 * @param amp optional amplitude parameter (not used by all spirals)
 */
@Override
public void calculate(Double[] pts, double twist, double amp) {
  double tot = 0.0;
  for (int i = 1; i < pts.length; i++) {        // find the total length
    tot += pts[i].distance(pts[i - 1]);
  }

  twistPts[0] = new Point3D(pts[0].x, pts[0].y, 0.0);   // first point is 0.0
  double cum = 0.0;     // the cumulative length
  for (int i = 1; i < twistPts.length; i++) {
    cum += pts[i].distance(pts[i - 1]);
    twistPts[i] = new Point3D(pts[i].x, pts[i].y, twist * Math.sin((Math.PI / 2.0) * cum / tot));
  }
}
项目:Equi    文件:SimpleGraphView3D.java   
public void addEdge(Point3D start, Point3D end, Color color) {
    node3D.addCylinder(
            start.getX(), start.getY(), start.getZ(),
            end.getX(), end.getY(), end.getZ(),
            getMaterial(color)
    );
}
项目:FXyzLib    文件:Ray.java   
/**
 * Projects the Ray from new <code>origin</code> along <code>direction</code> by <code>distance</code>
 * @param orig the new origin point
 * @param dir the new direction of travel
 * @param dist distance to project ray
 * @return sets origin and returns projected position
 */
public Point3D setProject(Point3D orig, Point3D dir, double dist){
    setOrigin(orig);
    setDirection(dir);
    setPosition(getOrigin().add((getDirection().normalize().multiply(dist))));

    return getPosition();
}
项目:FXyzLib    文件:Drag3DObject.java   
public Vec3d localToScene(Vec3d pt, Vec3d result) {
    Point3D res = camera.localToParentTransformProperty().get().transform(pt.x, pt.y, pt.z);
    if (camera.getParent() != null) {
        res = camera.getParent().localToSceneTransformProperty().get().transform(res);
    }
    result.set(res.getX(), res.getY(), res.getZ());
    return result;
}
项目:FXyzLib    文件:RayTest2.java   
public boolean intersects(int face, Point3D v0, Point3D v1, Point3D v2) {

    Point3D diff = origin.subtract(v0);
    Point3D edge1 = v1.subtract(v0);
    Point3D edge2 = v2.subtract(v0);
    Point3D norm = edge1.crossProduct(edge2);

    double dirDotNorm = direction.dotProduct(norm);
    double sign;
    if (dirDotNorm > 0.0000001) {
        sign = 1;
    } else if (dirDotNorm < -0.0000001) {
        sign = -1;
        dirDotNorm = -dirDotNorm;
    } else {
        return false;
    }

    double dirDotDiffxEdge2 = sign * direction.dotProduct(diff.crossProduct(edge2));
    if (dirDotDiffxEdge2 >= 0.0) {

        double dirDotEdge1xDiff = sign * direction.dotProduct(edge1.crossProduct(diff));

        if (dirDotEdge1xDiff >= 0.0) {
            if (dirDotEdge1xDiff <= dirDotNorm) {
                double diffDotNorm = -sign * diff.dotProduct(norm);
                if (diffDotNorm >= 0.0) {
                    intersectedFaces.add(face);
                    return true;
                }
            }
        }
    }
    return false;
}
项目:FXTutorials    文件:Tutorial.java   
private void placeCube(Point3D point) {
    Random random = new Random();
    Cube cube = new Cube(1, Color.rgb(random.nextInt(150) + 100, random.nextInt(150) + 100, random.nextInt(250)));
    cube.setTranslateX(point.getX());
    cube.setTranslateY(point.getY());
    cube.setTranslateZ(point.getZ());
    worldRoot.getChildren().add(cube);
}