Search in sources :

Example 46 with Point3D

use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.

the class SpringHelper method getS.

public Point3D getS(int t, float cu, float su) {
    Point3D[] trihedron = trihedrons.get(t);
    // S[t,u]
    Point3D p = trihedron[SpringHelper.tR].add(trihedron[SpringHelper.tN].multiply(cu).add(trihedron[SpringHelper.tB].multiply(su)));
    // [0-<=2Pi]
    p.f = ((float) (t * arc) / (float) subDivLength);
    return p;
}
Also used : Point3D(org.fxyz.geometry.Point3D)

Example 47 with Point3D

use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.

the class Text3DHelper method getPoints.

private void getPoints(PathElement elem) {
    if (elem instanceof MoveTo) {
        list = new ArrayList<>();
        p0 = new Point3D((float) ((MoveTo) elem).getX(), (float) ((MoveTo) elem).getY(), 0f);
        list.add(p0);
    } else if (elem instanceof LineTo) {
        list.add(new Point3D((float) ((LineTo) elem).getX(), (float) ((LineTo) elem).getY(), 0f));
    } else if (elem instanceof CubicCurveTo) {
        Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
        IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalCubicBezier((CubicCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
    } else if (elem instanceof QuadCurveTo) {
        Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
        IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalQuadBezier((QuadCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
    } else if (elem instanceof ClosePath) {
        list.add(p0);
        // stored in a LineSegment: a continuous line that can change direction
        if (Math.abs(getArea()) > 0.001) {
            LineSegment line = new LineSegment(text);
            line.setHole(isHole());
            line.setPoints(list);
            line.setPath(generatePath());
            line.setOrigen(p0);
            polis.add(line);
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) QuadCurveTo(javafx.scene.shape.QuadCurveTo) Color(javafx.scene.paint.Color) ClosePath(javafx.scene.shape.ClosePath) CubicCurveTo(javafx.scene.shape.CubicCurveTo) LineTo(javafx.scene.shape.LineTo) Font(javafx.scene.text.Font) PathElement(javafx.scene.shape.PathElement) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Text(javafx.scene.text.Text) List(java.util.List) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) MoveTo(javafx.scene.shape.MoveTo) Point2D(javafx.geometry.Point2D) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) QuadCurveTo(javafx.scene.shape.QuadCurveTo) Point3D(org.fxyz.geometry.Point3D) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 48 with Point3D

use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.

the class WeightedPoint method updatePhysics.

public void updatePhysics(double dt, double t) {
    synchronized (this) {
        if (isAnchored()) {
            setPosition(getAnchorPosition());
            return;
        }
        Point3D vel = new Point3D((position.x - oldPosition.x), (position.y - oldPosition.y), (position.z - oldPosition.z));
        float dtSq = (float) (dt * dt);
        // calculate the next position using Verlet Integration
        Point3D next = new Point3D(position.x + (vel.x + (((force.x / (float) (mass)) * 0.5f) * dtSq)), position.y + (vel.y + (((force.y / (float) (mass)) * 0.5f) * dtSq)), position.z + (vel.z + (((force.z / (float) (mass)) * 0.5f) * dtSq)));
        // reset variables
        setOldPosition(position);
        setPosition(next);
        clearForces();
    // log.log(Level.INFO, "\n Velocity: {0}", vel);
    }
}
Also used : Point3D(org.fxyz.geometry.Point3D)

Aggregations

Point3D (org.fxyz.geometry.Point3D)48 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 List (java.util.List)12 Face3 (org.fxyz.geometry.Face3)12 Collectors (java.util.stream.Collectors)10 IntStream (java.util.stream.IntStream)10 Group (javafx.scene.Group)10 Translate (javafx.scene.transform.Translate)10 ArrayList (java.util.ArrayList)9 Point2D (javafx.geometry.Point2D)9 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 Scene (javafx.scene.Scene)9 KeyCode (javafx.scene.input.KeyCode)9 TriangleMesh (javafx.scene.shape.TriangleMesh)9 Rotate (javafx.scene.transform.Rotate)9 PointLight (javafx.scene.PointLight)8 MouseEvent (javafx.scene.input.MouseEvent)8 DoubleProperty (javafx.beans.property.DoubleProperty)7 IntegerProperty (javafx.beans.property.IntegerProperty)7 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)7