Package toxi.geom

Examples of toxi.geom.Triangle3D


    public void testAABBTri() {
        AABB box = new AABB(new Vec3D(), new Vec3D(100, 100, 100));
        Vec3D a = new Vec3D(-90, 0, 0);
        Vec3D b = new Vec3D(-110, -200, 0);
        Vec3D c = new Vec3D(-110, 200, 0);
        Triangle3D tri = new Triangle3D(a, b, c);
        System.out.println(box.intersectsTriangle(tri));
    }
View Full Code Here


        faces = new ArrayList<Face>(numF);
        return this;
    }

    public boolean intersectsRay(Ray3D ray) {
        Triangle3D tri = intersector.getTriangle();
        for (Face f : faces) {
            tri.set(f.a, f.b, f.c);
            if (intersector.intersectsRay(ray)) {
                return true;
            }
        }
        return false;
View Full Code Here

        addFace(f.a, f.b, b2);
        addFace(f.b, c2, b2);
        addFace(f.b, f.c, c2);
        addFace(f.c, a2, c2);
        addFace(f.c, f.a, a2);
        return new Triangle3D(a2, b2, c2);
    }
View Full Code Here

     * manipulating them will not impact the originals.
     *
     * @return triangle copy of this mesh face
     */
    public Triangle3D toTriangle() {
        return new Triangle3D(a.copy(), b.copy(), c.copy());
    }
View Full Code Here

    public void testCentroid() {
        Vec3D a = new Vec3D(100, 0, 0);
        Vec3D b = new Vec3D(0, 100, 0);
        Vec3D c = new Vec3D(0, 0, 100);
        Triangle3D t = new Triangle3D(a, b, c);
        ReadonlyVec3D centroid = t.computeCentroid();
        assertTrue("incorrect centroid",
                centroid.equals(new Vec3D(100, 100, 100).scaleSelf(1f / 3)));
    }
View Full Code Here

    public void testContainment() {
        Vec3D a = new Vec3D(100, 0, 0);
        Vec3D b = new Vec3D(0, 100, 0);
        Vec3D c = new Vec3D(0, 0, 100);
        Triangle3D t = new Triangle3D(a, b, c);
        assertTrue(t.containsPoint(a));
        assertTrue(t.containsPoint(b));
        assertTrue(t.containsPoint(c));
        assertTrue(t.containsPoint(t.computeCentroid()));
        assertFalse(t.containsPoint(a.add(0.1f, 0, 0)));
        t.flipVertexOrder();
        assertTrue(t.containsPoint(t.computeCentroid()));
    }
View Full Code Here

        t.flipVertexOrder();
        assertTrue(t.containsPoint(t.computeCentroid()));
    }

    public void testEquilateral() {
        Triangle3D t = Triangle3D.createEquilateralFrom(new Vec3D(-100, 0, 0),
                new Vec3D(100, 0, 0));

    }
View Full Code Here

    public void testNormal() {
        Vec3D a = new Vec3D(0, 100, 0);
        Vec3D b = new Vec3D(100, 0, 0);
        Vec3D c = new Vec3D(-100, -100, 0);
        Triangle3D t = new Triangle3D(a, b, c);
        ReadonlyVec3D n = t.computeNormal();
        assertTrue("normal wrong", n.equals(new Vec3D(0, 0, 1)));
    }
View Full Code Here

import toxi.geom.Vec3D;

public class PlaneTest extends TestCase {

    public void testContainment() {
        Triangle3D t = new Triangle3D(new Vec3D(-100, 0, 0), new Vec3D(0, 0,
                -100), new Vec3D(0, 0, 100));
        Plane pl = new Plane(t.computeCentroid(), t.computeNormal());
    }
View Full Code Here

            Vec3D a = getVertexAtCell((int) xx, (int) zz);
            Vec3D b = getVertexAtCell(x2, (int) zz);
            Vec3D c = getVertexAtCell(x2, z2);
            Vec3D d = getVertexAtCell((int) xx, z2);
            Ray3D r = new Ray3D(new Vec3D(x, 10000, z), new Vec3D(0, -1, 0));
            TriangleIntersector i = new TriangleIntersector(new Triangle3D(a,
                    b, d));
            if (i.intersectsRay(r)) {
                isec = i.getIntersectionData();
            } else {
                i.setTriangle(new Triangle3D(b, c, d));
                i.intersectsRay(r);
                isec = i.getIntersectionData();
            }
        }
        return isec;
View Full Code Here

TOP

Related Classes of toxi.geom.Triangle3D

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.