Package barsuift.simLife.j3d

Examples of barsuift.simLife.j3d.Point3dState


    /**
     * Test with 3 leaves, one of which has 0 for area
     */
    public void testGetRandomLeafToIncrease4() {
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setEndPoint1(new Point3dState(0, 0, 0));
        leaf3D1.setEndPoint2(new Point3dState(0, 0, 0));
        // this is to ensure the leaf is not consedered to have reached its maximum size
        leaf3D1.setInitialEndPoint1(new Point3dState(0.2, 0, 0));
        leaf3D1.setInitialEndPoint2(new Point3dState(0, 0.2, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D2.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeaf3DState leaf3D3 = new TreeLeaf3DState();
        leaf3D3.setEndPoint1(new Point3dState(3, 0, 0));
        leaf3D3.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setId(new Long(1));
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setId(new Long(2));
View Full Code Here


    /**
     * Test with 2 leaves, one of which has 0 for area
     */
    public void testGetRandomLeafToIncrease5() {
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setEndPoint1(new Point3dState(0, 0, 0));
        leaf3D1.setEndPoint2(new Point3dState(0, 0, 0));
        // this is to ensure the leaf is not consedered to have reached its maximum size
        leaf3D1.setInitialEndPoint1(new Point3dState(0.2, 0, 0));
        leaf3D1.setInitialEndPoint2(new Point3dState(0, 0.2, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D2.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setId(new Long(1));
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setId(new Long(2));
View Full Code Here

        int nbLeaves = leaveStates.size();
        assertTrue(nbLeaves >= 2);
        assertTrue(nbLeaves <= 4);
        for (int index = 0; index < nbLeaves; index++) {
            TreeLeafState leafState = leaveStates.get(index);
            Point3dState leafAttachPoint = leafState.getLeaf3DState().getLeafAttachPoint();
            PointTestHelper.assertPointIsWithinBounds(leafAttachPoint.toPointValue(), new Point3d(0, 0, 0),
                    branchPartEndPoint);
        }

        Long id1 = branchPartState.getId();
        assertNotNull(id1);
View Full Code Here

     * <li>end point 2 : 10 * initial end point 2</li>
     * <li>rotation : a random number between 0 and 2 PI</li>
     * </ul>
     */
    public TreeLeaf3DState createRandomTreeLeaf3DState(Point3d leafAttachPoint) {
        Point3dState leafAttachPointState = new Point3dState(leafAttachPoint);
        Point3dState initialEndPoint1 = new Point3dState(-0.02 + Randomizer.random1() / 10, -0.04
                + Randomizer.random1() / 10, 0);
        Point3dState initialEndPoint2 = new Point3dState(0.02 + Randomizer.random1() / 10, -0.04 + Randomizer.random1()
                / 10, 0);
        Point3dState endPoint1 = new Point3dState(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10,
                initialEndPoint1.getZ() * 10);
        Point3dState endPoint2 = new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                initialEndPoint2.getZ() * 10);
        double rotation = Randomizer.randomRotation();
        return new TreeLeaf3DState(leafAttachPointState, initialEndPoint1, initialEndPoint2, endPoint1, endPoint2,
                rotation);
    }
View Full Code Here

     * <li>end point 2 : initial end point 2</li>
     * <li>rotation : a random number between 0 and 2 PI</li>
     * </ul>
     */
    public TreeLeaf3DState createNewTreeLeaf3DState(Point3d leafAttachPoint) {
        Point3dState leafAttachPointState = new Point3dState(leafAttachPoint);
        Point3dState initialEndPoint1 = new Point3dState(-0.02 + Randomizer.random1() / 10, -0.04
                + Randomizer.random1() / 10, 0);
        Point3dState initialEndPoint2 = new Point3dState(0.02 + Randomizer.random1() / 10, -0.04 + Randomizer.random1()
                / 10, 0);
        Point3dState endPoint1 = new Point3dState(initialEndPoint1);
        Point3dState endPoint2 = new Point3dState(initialEndPoint2);
        double rotation = Randomizer.randomRotation();
        return new TreeLeaf3DState(leafAttachPointState, initialEndPoint1, initialEndPoint2, endPoint1, endPoint2,
                rotation);
    }
View Full Code Here

        return tree.getTrunk().getTreeTrunkD();
    }

    @Override
    public Tree3DState getState() {
        return new Tree3DState(new Point3dState(translationVector));
    }
View Full Code Here

        return endPoint;
    }

    @Override
    public TreeBranchPart3DState getState() {
        return new TreeBranchPart3DState(new Point3dState(endPoint));
    }
View Full Code Here

import barsuift.simLife.j3d.Point3dState;

public class TreeBranch3DStateFactory {

    public TreeBranch3DState createRandomTreeBranch3DState(Vector3d translationVector) {
        Point3dState translationVectorState = new Point3dState(new Point3d(translationVector));
        return new TreeBranch3DState(translationVectorState);
    }
View Full Code Here

        return parts.get(parts.size() - 1).getBranchPart3D().getEndPoint();
    }

    @Override
    public TreeBranch3DState getState() {
        return new TreeBranch3DState(new Point3dState(translationVector));
    }
View Full Code Here

        return AreaHelper.computeArea(leafGeometry);
    }

    @Override
    public boolean isMaxSizeReached() {
        Point3dState initialEndPoint1 = state.getInitialEndPoint1();
        double maxX1 = MAX_INCREASE_FACTOR * initialEndPoint1.getX();
        double maxY1 = MAX_INCREASE_FACTOR * initialEndPoint1.getY();
        double maxZ1 = MAX_INCREASE_FACTOR * initialEndPoint1.getZ();
        Point3d actualEndPoint1 = state.getEndPoint1().toPointValue();
        boolean areAlmostEquals1 = PointHelper.areAlmostEquals(actualEndPoint1, new Point3d(maxX1, maxY1, maxZ1));
        if (!areAlmostEquals1) {
            return false;
        }
        Point3dState initialEndPoint2 = state.getInitialEndPoint2();
        double maxX2 = MAX_INCREASE_FACTOR * initialEndPoint2.getX();
        double maxY2 = MAX_INCREASE_FACTOR * initialEndPoint2.getY();
        double maxZ2 = MAX_INCREASE_FACTOR * initialEndPoint2.getZ();
        Point3d actualEndPoint2 = state.getEndPoint2().toPointValue();
        boolean areAlmostEquals2 = PointHelper.areAlmostEquals(actualEndPoint2, new Point3d(maxX2, maxY2, maxZ2));
        if (!areAlmostEquals2) {
            return false;
        }
View Full Code Here

TOP

Related Classes of barsuift.simLife.j3d.Point3dState

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.