Search in sources :

Example 31 with Point3D

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

the class SegmentedSphereMesh method createSegmentedSphere.

private TriangleMesh createSegmentedSphere(int subDivY, int cropX, int cropY, float radius, float tubeStartAngle, float xOffset, float yOffset, float zOffset) {
    listVertices.clear();
    listTextures.clear();
    listFaces.clear();
    int subDivX = subDivY;
    int numDivX = subDivX + 1 - 2 * cropX;
    float pointX, pointY, pointZ;
    areaMesh.setWidth((1 - 2 * cropX / subDivX) * 2d * Math.PI * radius);
    areaMesh.setHeight((1 - 2 * cropY / subDivY) * 2d * Math.PI * radius);
    a = new Affine();
    if (center.get() != null) {
        a = a.createConcatenation(new Translate(center.get().x, center.get().y, center.get().z));
    }
    // Create points
    for (int y = cropY; y <= subDivY - cropY; y++) {
        float dy = (float) y / subDivY;
        for (int x = cropX; x <= subDivX - cropX; x++) {
            float dx = (float) x / subDivX;
            if (cropX > 0 || (cropX == 0 && x < subDivX)) {
                pointX = (float) ((radius * Math.sin((-1d + dy) * Math.PI)) * (Math.cos((-1d + 2d * dx) * Math.PI) + xOffset));
                pointZ = (float) ((radius * Math.sin((-1d + dy) * Math.PI)) * (Math.sin((-1d + 2d * dx) * Math.PI) + yOffset));
                pointY = (float) (radius * Math.cos((-1d + dy) * Math.PI) * zOffset);
                Point3D ta = transform(pointX, pointY, pointZ);
                listVertices.add(ta);
            }
        }
    }
    // Create texture coordinates
    // if(exterior.get()){
    createTexCoords(subDivX - 2 * cropX, subDivY - 2 * cropY);
    // Create textures indices
    for (int y = cropY; y < subDivY - cropY; y++) {
        for (int x = cropX; x < subDivX - cropX; x++) {
            int p00 = (y - cropY) * numDivX + (x - cropX);
            int p01 = p00 + 1;
            int p10 = p00 + numDivX;
            int p11 = p10 + 1;
            if (y < subDivY - 1) {
                listTextures.add(new Face3(p00, p10, p11));
            }
            if (y > 0) {
                listTextures.add(new Face3(p11, p01, p00));
            }
        }
    }
    // Create faces indices
    for (int y = cropY; y < subDivY - cropY; y++) {
        for (int x = cropX; x < subDivX - cropX; x++) {
            int p00 = (y - cropY) * ((cropX > 0) ? numDivX : numDivX - 1) + (x - cropX);
            int p01 = p00 + 1;
            if (cropX == 0 && x == subDivX - 1) {
                p01 -= subDivX;
            }
            int p10 = p00 + ((cropX > 0) ? numDivX : numDivX - 1);
            // if(cropY==0 && y==subDivY-1){
            // p10-=subDivY*((cropX>0)?numDivX:numDivX-1);
            // }
            int p11 = p10 + 1;
            if (cropX == 0 && x == subDivX - 1) {
                p11 -= subDivX;
            }
            if (y < subDivY - 1) {
                listFaces.add(new Face3(p00, p10, p11));
            }
            if (y > 0) {
                listFaces.add(new Face3(p11, p01, p00));
            }
        }
    }
    return createMesh();
}
Also used : Point3D(org.fxyz.geometry.Point3D) Affine(javafx.scene.transform.Affine) Translate(javafx.scene.transform.Translate) Face3(org.fxyz.geometry.Face3)

Example 32 with Point3D

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

the class Text3DMesh method createLetter.

private void createLetter(String letter) {
    Text3DHelper helper = new Text3DHelper(letter, font.get(), fontSize.get());
    List<Point3D> origin = helper.getOffset();
    final int ind = indSegments.get();
    helper.getLineSegment().stream().map(poly -> poly.getPath()).forEach(path -> letterPath = Shape.union(letterPath, path));
    helper.getLineSegment().stream().forEach(poly -> {
        final List<Point3D> points = poly.getPoints();
        List<List<Point3D>> holes = null;
        if (poly.getHoles().size() > 0) {
            holes = poly.getHoles().stream().map(LineSegment::getPoints).collect(Collectors.toList());
        }
        List<Point3D> invert = IntStream.range(0, points.size()).mapToObj(i -> points.get(points.size() - 1 - i)).distinct().collect(Collectors.toList());
        Bounds bounds = null;
        if (joinSegments.get()) {
            bounds = letterPath.getBoundsInParent();
        }
        TriangulatedMesh polyMesh = new TriangulatedMesh(invert, holes, level.get(), height.get(), 0d, bounds);
        if (indSegments.get() > ind && joinSegments.get()) {
            /*
                Combine new polyMesh with previous polyMesh into one single polyMesh
                */
            MeshHelper mh = new MeshHelper((TriangleMesh) meshes.get(meshes.size() - 1).getMesh());
            MeshHelper mh1 = new MeshHelper((TriangleMesh) polyMesh.getMesh());
            mh1.addMesh(mh);
            polyMesh.updateMesh(mh1);
            meshes.set(meshes.size() - 1, polyMesh);
        } else {
            meshes.add(polyMesh);
        }
        polyMesh.getTransforms().addAll(new Translate(offset.get(ind).x - origin.get(0).x + indLetters.get() * gap.doubleValue(), 0, 0));
        polyMesh.setCullFace(CullFace.BACK);
        polyMesh.setDrawMode(DrawMode.FILL);
        polyMesh.setDepthTest(DepthTest.ENABLE);
        polyMesh.setId(poly.getLetter());
        System.out.println("l " + poly.getLetter());
        indSegments.getAndIncrement();
    });
    indLetters.getAndIncrement();
}
Also used : IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Function(java.util.function.Function) IntegerProperty(javafx.beans.property.IntegerProperty) CullFace(javafx.scene.shape.CullFace) TriangleMesh(javafx.scene.shape.TriangleMesh) ArrayList(java.util.ArrayList) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ColorPalette(org.fxyz.utils.Palette.ColorPalette) Mesh(javafx.scene.shape.Mesh) Patterns(org.fxyz.utils.Patterns) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) Color(javafx.scene.paint.Color) Translate(javafx.scene.transform.Translate) TextureMode(org.fxyz.shapes.primitives.helper.TextureMode) Group(javafx.scene.Group) DrawMode(javafx.scene.shape.DrawMode) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Stream(java.util.stream.Stream) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) DepthTest(javafx.scene.DepthTest) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) Translate(javafx.scene.transform.Translate) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment)

Example 33 with Point3D

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

the class TriangulatedMesh method createMesh.

private TriangleMesh createMesh(int level) {
    TriangleMesh m0 = null;
    if (level > 0) {
        m0 = createMesh(level - 1);
    }
    if (level == 0) {
        // check for duplicates or too close
        List<Integer> duplicates = IntStream.range(0, pointsExterior.size()).boxed().filter(i -> pointsExterior.get(i).substract(pointsExterior.get(i == pointsExterior.size() - 1 ? 0 : i + 1)).magnitude() < 100 * EPSILON).map(i -> i).collect(Collectors.toList());
        duplicates.stream().sorted(Collections.reverseOrder()).forEach(i -> pointsExterior.remove(i.intValue()));
        List<PolygonPoint> list = pointsExterior.stream().map(p -> new PolygonPoint(p.x, p.y)).collect(Collectors.toList());
        Polygon poly = new Polygon(list);
        if (bounds.get() != null) {
            maxX = bounds.get().getMaxX();
            minX = bounds.get().getMinX();
            maxY = bounds.get().getMaxY();
            minY = bounds.get().getMinY();
        } else {
            maxX = pointsExterior.stream().mapToDouble(p -> p.x).max().getAsDouble();
            maxY = pointsExterior.stream().mapToDouble(p -> p.y).max().getAsDouble();
            minX = pointsExterior.stream().mapToDouble(p -> p.x).min().getAsDouble();
            minY = pointsExterior.stream().mapToDouble(p -> p.y).min().getAsDouble();
        }
        double rad = getHoleRadius();
        if (pointsHoles != null) {
            steinerPoints = 0;
            numHoles = pointsHoles.size();
            // holes
            pointsHoles.forEach(pHole -> {
                // hole
                List<PolygonPoint> hole = pHole.stream().distinct().map(p -> new PolygonPoint(p.x, p.y)).collect(Collectors.toList());
                holePoints.add(hole.size());
                Polygon polyIn = new Polygon(hole);
                poly.addHole(polyIn);
                holes.add(hole);
            });
        } else if (rad > 0d) {
            steinerPoints = 0;
            numHoles = 1;
            int num = 200;
            holePoints.add(num);
            // circular hole
            List<PolygonPoint> hole = IntStream.range(0, num).mapToObj(i -> new PolygonPoint((maxX + minX) / 2d + rad * Math.cos((num - i) * 2d * Math.PI / num), (maxY + minY) / 2d + rad * Math.sin((num - i) * 2d * Math.PI / num))).collect(Collectors.toList());
            Polygon polyIn = new Polygon(hole);
            poly.addHole(polyIn);
            holes.add(hole);
        } else {
            double radSteiner = Math.sqrt(Math.pow(maxX - minX, 2) + Math.pow(maxY - minY, 2)) / 8d;
            // steiner points
            steiner = IntStream.range(0, steinerPoints).mapToObj(i -> new PolygonPoint((maxX + minX) / 2d + radSteiner * Math.cos(i * 2d * Math.PI / steinerPoints), (maxY + minY) / 2d + radSteiner * Math.sin(i * 2d * Math.PI / steinerPoints))).collect(Collectors.toList());
            poly.addSteinerPoints(steiner);
        }
        PolygonSet ps = new PolygonSet(poly);
        Poly2Tri.triangulate(ps);
        Polygon polRes = ps.getPolygons().get(0);
        List<DelaunayTriangle> tri = polRes.getTriangles();
        points1 = polRes.getPoints();
        extPoints = points1.size();
        if (pointsHoles != null || rad > 0d) {
            holes.forEach(hole -> hole.forEach(points1::add));
        } else {
            steiner.forEach(points1::add);
        }
        int totalHolePoints = holePoints.stream().reduce(0, Integer::sum);
        int numPoints = extPoints + steinerPoints + totalHolePoints;
        FloatCollector pointsBottom = points1.stream().flatMapToDouble(p -> DoubleStream.of(p.getX(), p.getY(), 0d)).collect(() -> new FloatCollector(points1.size() * 3), FloatCollector::add, FloatCollector::join);
        FloatCollector pointsTop = points1.stream().flatMapToDouble(p -> DoubleStream.of(p.getX(), p.getY(), height.get())).collect(() -> new FloatCollector(points1.size() * 3), FloatCollector::add, FloatCollector::join);
        pointsBottom.join(pointsTop);
        points0 = pointsBottom.toArray();
        numVertices = points0.length / 3;
        FloatCollector texBottom = points1.stream().flatMapToDouble(p -> DoubleStream.of((p.getX() - minX) / (maxX - minX), (p.getY() - minY) / (maxY - minY))).collect(() -> new FloatCollector(points1.size() * 2), FloatCollector::add, FloatCollector::join);
        FloatCollector texTop = points1.stream().flatMapToDouble(p -> DoubleStream.of((p.getX() - minX) / (maxX - minX), (p.getY() - minY) / (maxY - minY))).collect(() -> new FloatCollector(points1.size() * 2), FloatCollector::add, FloatCollector::join);
        texBottom.join(texTop);
        texCoord0 = texBottom.toArray();
        numTexCoords = texCoord0.length / 2;
        texCoord1 = IntStream.range(0, numTexCoords).mapToObj(i -> new Point2D(texCoord0[2 * i], texCoord0[2 * i + 1])).collect(Collectors.toList());
        List<int[]> listIndices = tri.stream().map((DelaunayTriangle t) -> {
            int[] pIndex = new int[3];
            for (int j = 0; j < 3; j++) {
                final TriangulationPoint dt = t.points[j];
                int[] toArray = IntStream.range(0, points1.size()).filter(i -> points1.get(i).equals(dt)).toArray();
                if (toArray.length > 0) {
                    pIndex[j] = toArray[0];
                } else {
                    System.out.println("Error " + points1);
                }
            }
            return pIndex;
        }).collect(Collectors.toList());
        // faces
        // base
        IntStream streamBottom = listIndices.stream().map(i -> IntStream.of(i[0], i[0], i[2], i[2], i[1], i[1])).flatMapToInt(i -> i);
        // top
        IntStream streamTop = listIndices.stream().map(i -> IntStream.of(numPoints + i[0], numPoints + i[0], numPoints + i[1], numPoints + i[1], numPoints + i[2], numPoints + i[2])).flatMapToInt(i -> i);
        // vertical, exterior
        IntStream streamExtWalls = IntStream.range(0, extPoints - 1).mapToObj(i -> IntStream.of(i, i, i + 1, i + 1, i + 1 + numPoints, i + 1 + numPoints, i, i, i + 1 + numPoints, i + 1 + numPoints, i + numPoints, i + numPoints)).flatMapToInt(i -> i);
        // vertical, exterior, close polygon
        IntStream streamExtWallsClose = IntStream.of(extPoints - 1, extPoints - 1, 0, 0, 0 + numPoints, 0 + numPoints, extPoints - 1, extPoints - 1, 0 + numPoints, 0 + numPoints, numPoints + extPoints - 1, numPoints + extPoints - 1);
        if (totalHolePoints > 0) {
            // vertical, interior
            // holes
            int acuHolePoints0 = extPoints + steinerPoints, acuHolePoints1;
            IntStream streamIntWalls = IntStream.empty();
            for (List<PolygonPoint> hole : holes) {
                acuHolePoints1 = acuHolePoints0 + hole.size() - 1;
                IntStream streamIntWallsHole = IntStream.range(acuHolePoints0, acuHolePoints1).mapToObj(i -> IntStream.of(i, i, i + 1 + numPoints, i + 1 + numPoints, i + 1, i + 1, i, i, i + numPoints, i + numPoints, i + 1 + numPoints, i + 1 + numPoints)).flatMapToInt(i -> i);
                streamIntWalls = IntStream.concat(streamIntWalls, streamIntWallsHole);
                acuHolePoints0 = acuHolePoints1 + 1;
            }
            // vertical, interior, close holes
            // holes
            acuHolePoints0 = extPoints + steinerPoints;
            IntStream streamIntWallsClose = IntStream.empty();
            for (List<PolygonPoint> hole : holes) {
                acuHolePoints1 = acuHolePoints0 + hole.size() - 1;
                IntStream streamIntWallsCloseHole = IntStream.of(acuHolePoints1, acuHolePoints1, numPoints + acuHolePoints0, numPoints + acuHolePoints0, acuHolePoints0, acuHolePoints0, acuHolePoints1, acuHolePoints1, numPoints + acuHolePoints1, numPoints + acuHolePoints1, numPoints + acuHolePoints0, numPoints + acuHolePoints0);
                streamIntWallsClose = IntStream.concat(streamIntWallsClose, streamIntWallsCloseHole);
                acuHolePoints0 = acuHolePoints1 + 1;
            }
            faces0 = IntStream.concat(streamBottom, IntStream.concat(streamTop, IntStream.concat(streamExtWalls, IntStream.concat(streamExtWallsClose, IntStream.concat(streamIntWalls, streamIntWallsClose))))).toArray();
        } else {
            faces0 = IntStream.concat(streamBottom, IntStream.concat(streamTop, IntStream.concat(streamExtWalls, streamExtWallsClose))).toArray();
        }
        numFaces = faces0.length / 6;
    } else if (m0 != null) {
        points0 = new float[numVertices * m0.getPointElementSize()];
        m0.getPoints().toArray(points0);
        texCoord0 = new float[numTexCoords * m0.getTexCoordElementSize()];
        m0.getTexCoords().toArray(texCoord0);
        faces0 = new int[numFaces * m0.getFaceElementSize()];
        m0.getFaces().toArray(faces0);
    }
    List<Point3D> points1 = IntStream.range(0, numVertices).mapToObj(i -> new Point3D(points0[3 * i], points0[3 * i + 1], points0[3 * i + 2])).collect(Collectors.toList());
    texCoord1 = IntStream.range(0, numTexCoords).mapToObj(i -> new Point2D(texCoord0[2 * i], texCoord0[2 * i + 1])).collect(Collectors.toList());
    List<Face3> faces1 = IntStream.range(0, numFaces).mapToObj(i -> new Face3(faces0[6 * i], faces0[6 * i + 2], faces0[6 * i + 4])).collect(Collectors.toList());
    index.set(points1.size());
    map.clear();
    listFaces.clear();
    listVertices.clear();
    listVertices.addAll(points1);
    faces1.forEach(face -> {
        int v1 = face.p0;
        int v2 = face.p1;
        int v3 = face.p2;
        if (level > 0) {
            int a = getMiddle(v1, points1.get(v1), v2, points1.get(v2));
            int b = getMiddle(v2, points1.get(v2), v3, points1.get(v3));
            int c = getMiddle(v3, points1.get(v3), v1, points1.get(v1));
            listFaces.add(new Face3(v1, a, c));
            listFaces.add(new Face3(v2, b, a));
            listFaces.add(new Face3(v3, c, b));
            listFaces.add(new Face3(a, b, c));
        } else {
            listFaces.add(new Face3(v1, v2, v3));
        }
    });
    map.clear();
    numVertices = listVertices.size();
    numFaces = listFaces.size();
    List<Face3> textures1 = IntStream.range(0, faces0.length / 6).mapToObj(i -> new Face3(faces0[6 * i + 1], faces0[6 * i + 3], faces0[6 * i + 5])).collect(Collectors.toList());
    index.set(texCoord1.size());
    listTextures.clear();
    textures1.forEach(face -> {
        int v1 = face.p0;
        int v2 = face.p1;
        int v3 = face.p2;
        if (level > 0) {
            int a = getMiddle(v1, texCoord1.get(v1), v2, texCoord1.get(v2));
            int b = getMiddle(v2, texCoord1.get(v2), v3, texCoord1.get(v3));
            int c = getMiddle(v3, texCoord1.get(v3), v1, texCoord1.get(v1));
            listTextures.add(new Face3(v1, a, c));
            listTextures.add(new Face3(v2, b, a));
            listTextures.add(new Face3(v3, c, b));
            listTextures.add(new Face3(a, b, c));
        } else {
            listTextures.add(new Face3(v1, v2, v3));
        }
    });
    map.clear();
    texCoord0 = texCoord1.stream().flatMapToDouble(p -> DoubleStream.of(p.getX(), p.getY())).collect(() -> new FloatCollector(texCoord1.size() * 2), FloatCollector::add, FloatCollector::join).toArray();
    numTexCoords = texCoord0.length / 2;
    textureCoords = texCoord0;
    if (level == getLevel()) {
        areaMesh.setWidth(maxX - minX);
        areaMesh.setHeight(maxY - minY);
        rectMesh.setWidth((int) Math.sqrt(texCoord0.length));
        rectMesh.setHeight(texCoord0.length / ((int) Math.sqrt(texCoord0.length)));
        smoothingGroups = getSmoothingGroups(listVertices, listFaces);
    }
    return createMesh();
}
Also used : IntStream(java.util.stream.IntStream) HashMap(java.util.HashMap) DoubleProperty(javafx.beans.property.DoubleProperty) IntegerProperty(javafx.beans.property.IntegerProperty) CullFace(javafx.scene.shape.CullFace) TriangleMesh(javafx.scene.shape.TriangleMesh) ArrayList(java.util.ArrayList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelaunayTriangle(org.poly2tri.triangulation.delaunay.DelaunayTriangle) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Polygon(org.poly2tri.polygon.Polygon) Point2D(javafx.geometry.Point2D) ObjectProperty(javafx.beans.property.ObjectProperty) FloatCollector(org.fxyz.utils.FloatCollector) PolygonSet(org.poly2tri.polygon.PolygonSet) DrawMode(javafx.scene.shape.DrawMode) Collectors(java.util.stream.Collectors) DoubleStream(java.util.stream.DoubleStream) Poly2Tri(org.poly2tri.Poly2Tri) List(java.util.List) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) DepthTest(javafx.scene.DepthTest) Face3(org.fxyz.geometry.Face3) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) Collections(java.util.Collections) PolygonPoint(org.poly2tri.polygon.PolygonPoint) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) TriangleMesh(javafx.scene.shape.TriangleMesh) FloatCollector(org.fxyz.utils.FloatCollector) DelaunayTriangle(org.poly2tri.triangulation.delaunay.DelaunayTriangle) PolygonPoint(org.poly2tri.polygon.PolygonPoint) PolygonSet(org.poly2tri.polygon.PolygonSet) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.polygon.PolygonPoint) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Point2D(javafx.geometry.Point2D) Point3D(org.fxyz.geometry.Point3D) ArrayList(java.util.ArrayList) List(java.util.List) Polygon(org.poly2tri.polygon.Polygon) IntStream(java.util.stream.IntStream) Face3(org.fxyz.geometry.Face3)

Example 34 with Point3D

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

the class CurvedSpringHelper method getTau.

public double getTau(double t) {
    Point3D dR = new Point3D((float) (-((R + r * Math.cos(h * t)) * Math.sin(t)) - h * r * Math.cos(t) * Math.sin(h * t)), (float) (Math.cos(t) * (R + r * Math.cos(h * t)) - h * r * Math.sin(t) * Math.sin(h * t)), (float) (h * r * Math.cos(h * t)));
    // r''[t]
    Point3D ddR = new Point3D((float) (-(Math.cos(t) * (R + (1 + h * h) * r * Math.cos(h * t))) + 2 * h * r * Math.sin(t) * Math.sin(h * t)), (float) (-((R + (1 + h * h) * r * Math.cos(h * t)) * Math.sin(t)) - 2 * h * r * Math.cos(t) * Math.sin(h * t)), (float) (-(h * h * r * Math.sin(h * t))));
    // r'''[t]
    Point3D dddR = new Point3D((float) ((R + (1 + 3 * h * h) * r * Math.cos(h * t)) * Math.sin(t) + h * (3 + h * h) * r * Math.cos(t) * Math.sin(h * t)), (float) (-(Math.cos(t) * (R + (1 + 3 * h * h) * r * Math.cos(h * t))) + h * (3 + h * h) * r * Math.sin(t) * Math.sin(h * t)), (float) (-(h * h * h * r * Math.cos(h * t))));
    // r'[t]xr''[t] . r'''[t]
    float dRxddRxdddR = dR.crossProduct(ddR).dotProduct(dddR);
    // || r''[t]xr'[t] ||
    float ndRxddR = dR.crossProduct(ddR).magnitude();
    // tau[t] = r'[t]xr''[t].r'''[t] / || r''[t]xr'[t] ||^2
    return Math.abs(dRxddRxdddR / (float) Math.pow(ndRxddR, 2d));
}
Also used : Point3D(org.fxyz.geometry.Point3D)

Example 35 with Point3D

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

the class CurvedSpringHelper method getS.

public Point3D getS(int t, float cu, float su) {
    Point3D[] trihedron = trihedrons.get(t);
    // S[t,u]
    Point3D p = trihedron[CurvedSpringHelper.tR].add(trihedron[CurvedSpringHelper.tN].multiply(cu).add(trihedron[CurvedSpringHelper.tB].multiply(su)));
    // [0-<=2Pi]
    p.f = ((float) (t * arc) / (float) subDivLength);
    return p;
}
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