1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d.manipulation;
21
22 import javax.vecmath.*;
23 import javax.media.j3d.*;
24 import camera3d.action.ActionQueue;
25 import camera3d.action.ActionExecutor;
26 import camera3d.test.NodeTester;
27 import camera3d.MathUtility;
28 import camera3d.GeometryBag;
29 import camera3d.VcView;
30 import camera3d.TransformMode;
31 import camera3d.TransformScope;
32
33 /*
34 * Title: Câmera Virtual - LIVES
35 * Description: Câmera Virtual para Controle via LabVIEW
36 * Copyright: Copyright (c) 2001
37 * Company: Centro de Educação em Informática - SENAC - SP
38 */
39
40 /***
41 * Tests TranslationManipulator.
42 *
43 * @author Fábio Roberto de Miranda, Carlos da Silva dos Santos
44 * @version 1.0
45 */
46
47 class TransManipTester {
48
49 /***
50 * Simple main that tests the intersection computing and line/plane building functions
51 */
52 public static void main(String[] args) {
53 TranslationManipulator manip = new TranslationManipulator();
54 // First test: Using hand-coded plane and line data
55 NodeTester tester = new NodeTester();
56
57 Point3d planePoint = new Point3d(1.0, -1.0, 1.0);
58 GeometryBag bag = new GeometryBag();
59 tester.add(bag.getBranchGroup());
60
61 Vector3d planeVector = new Vector3d(0.0, 1.0, 0.0);
62 Point3d linePoint = new Point3d(1.0, 1.0, 1.0);
63 Vector3d lineVector = new Vector3d(0.0, -1.0, 0.0);
64 // Point to store result
65 Point3d result = new Point3d();
66 MathUtility.computeIntersection(result, linePoint, lineVector, planePoint, planeVector);
67
68 bag.addLine(linePoint, lineVector);
69 bag.addPlane(planePoint, planeVector);
70 bag.addPoint(result);
71
72 Transform3D tempT3D = new Transform3D();
73 tempT3D.rotZ(0.1);
74
75 for (int i=0; i < 40; i++) {
76 tempT3D.transform(lineVector);
77 MathUtility.computeIntersection(result, linePoint, lineVector, planePoint, planeVector);
78 //bag.addPlane(planePoint, planeVector);
79 bag.addPoint(result);
80 bag.addLine(linePoint, lineVector);
81 }
82
83 Vector4d testPlane = new Vector4d();
84
85 MathUtility.buildPlaneFromPointAndNormal(testPlane, planePoint, planeVector);
86
87 lineVector.set(0.0, -1.0, 0.0);
88 linePoint.z += 2.0;
89
90 bag.addPlane(testPlane);
91
92 for (int i=0; i < 10; i++) {
93 tempT3D.transform(lineVector);
94 //manip.computeIntersection(result, linePoint, lineVector, planePoint, planeVector);
95 MathUtility.computeIntersection(result, linePoint, lineVector, testPlane);
96 //bag.addPlane(planePoint, planeVector);
97 bag.addPoint(result);
98 bag.addLine(linePoint, lineVector);
99 }
100
101 //manip.buildPlanePointAndNormal(testPlane, planeVector, planePoint);
102 //bag.addPlane(planePoint, planeVector);
103 //System.out.println("__Point:"+planePoint);
104 //System.out.println("__Normal:"+planeVector);
105
106
107 //Second test: convert plan above to Vector4d form and test second intersection utility
108 Vector4d plane = new Vector4d();
109 // We'll need 3 points contained in that plane, planePoint and two others
110 Point3d planePt2 = new Point3d(2.0, -1.0, 1.0);
111 Point3d planePt3 = new Point3d(3.0, -1.0, 5.0);
112
113 //manip.buildPickingPlaneDescription(plane, planePoint, planePt2, planePt3);
114 // Use newly computed plane to test other intersection function
115 //MathUtility.computeIntersection(result, linePoint, lineVector, plane);
116
117 }
118 }
This page was automatically generated by Maven