Package org.kalimullin.fsraytracer.geometry

Examples of org.kalimullin.fsraytracer.geometry.Point


    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        switch (qName.toLowerCase()) {
            case "point":
                currentPoint = new Point();
                break;
            case "face":
                currentFacePoints = new HashSet<>();
                break;
            case "id":
View Full Code Here


        String[] rayData = string.split(";");
        if (3 != rayData.length)
            throw new IllegalArgumentException("String must be following format: " +
                    "\"id;originX,originY,originZ;dirX,dirY,dirZ\"");
        Integer id = Integer.parseInt(rayData[0]);
        Point originPoint = Point.getPointFromString(rayData[1]);
        Point directionVector = Point.getPointFromString(rayData[2]);
        return new Ray(originPoint, directionVector, id);
    }
View Full Code Here

    @Test
    public void testRayTraceHit() {
        // test data has only one object
        SceneObject pyramid = (SceneObject) scene.getSceneObjects().toArray()[0];
        HitData expectedHitData = new HitData(new HitPoint(new Point(-0.5, -0.5, 0), Math.sqrt(9 * 3)), pyramid);
        assertEquals(expectedHitData, scene.traceRay(new Ray(new Point(-3.5, -3.5, -3), new Point(1, 1, 1))));
    }
View Full Code Here

        assertEquals(expectedHitData, scene.traceRay(new Ray(new Point(-3.5, -3.5, -3), new Point(1, 1, 1))));
    }

    @Test
    public void testRayMiss() {
        assertEquals(HitData.MISS, scene.traceRay(new Ray(new Point(10,10,10), new Point(1,1,1))));
    }
View Full Code Here

    @Before
    public void setUp() {
        this.invalidXml = new File("src/test/resources/invalid.xml");
        this.validXml = new File("src/test/resources/simpleScene.xml");
        pyramidSceneObjectSet = new HashSet<>();
        Point point1 = new Point(-1.8, -1.8, 0);
        Point point2 = new Point(1.8, -1.8, 0);
        Point point3 = new Point(0, 1.8, 0);
        Point point4 = new Point(0, 0, 1.2);
        Face face1 = new Face(point1, point2, point3);
        Face face2 = new Face(point1, point2, point4);
        Face face3 = new Face(point1, point4, point3);
        Face face4 = new Face(point4, point3, point2);
        Polygon polygon1 = new Polygon(face1);
View Full Code Here

        assertEquals(GeometryTestData.PYRAMID, pyramid);
    }

    @Test
    public void testHitPoints() {
        Ray xyRay = new Ray(new Point(3, 3, -5), new Point(0, 0, 2));
        assertEquals(new HitPoint(new Point(3,3,0), 5), GeometryTestData.PYRAMID.getHitPoint(xyRay));
        Ray yzRay = new Ray(new Point(-10, 3, 3), new Point(2, 0, 0));
        assertEquals(new HitPoint(new Point(0, 3, 3), 10), GeometryTestData.PYRAMID.getHitPoint(yzRay));
        Ray xzRay = new Ray(new Point(3, -5, 3), new Point(0, 2, 0));
        assertEquals(new HitPoint(new Point(3, 0, 3), 5), GeometryTestData.PYRAMID.getHitPoint(xzRay));
    }
View Full Code Here

        assertEquals(new HitPoint(new Point(3, 0, 3), 5), GeometryTestData.PYRAMID.getHitPoint(xzRay));
    }

    @Test
    public void testMiss() {
        Ray missRay = new Ray(new Point(20,20,20), new Point(1,1,1));
        assertEquals(HitPoint.MISSED, GeometryTestData.PYRAMID.getHitPoint(missRay));
    }
View Full Code Here

    HitPoint hitPoint;

    @Before
    public void setUp() {
        hitPoint = new HitPoint(new Point(5,5,5), 10);
    }
View Full Code Here

        hitPoint = new HitPoint(new Point(5,5,5), 10);
    }

    @Test
    public void testEquals() {
        assertEquals(new HitPoint(new Point(5,5,5), 10), hitPoint);
    }
View Full Code Here

    }

    @Test
    public void testComparator() {
        List<HitPoint> hitPointList = new ArrayList<>();
        HitPoint hitPointSeven = new HitPoint(new Point(4,9,1), 7);
        HitPoint hitPointNine = new HitPoint(new Point(6,1,9), 9);
        HitPoint hitPointTen = new HitPoint(new Point(1,1,0), 10);
        HitPoint hitPointTwenty = new HitPoint(new Point(6,9,6), 20);
        HitPoint hitPointTwentyTwo = new HitPoint(new Point(0,0,1), 22);
        hitPointList.add(hitPointNine);
        hitPointList.add(hitPointTwenty);
        hitPointList.add(HitPoint.MISSED);
        hitPointList.add(hitPointTwentyTwo);
        hitPointList.add(hitPointTen);
View Full Code Here

TOP

Related Classes of org.kalimullin.fsraytracer.geometry.Point

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.