Consider the simplest series of operations that must
From AwtRenderingEngine.java private int xScreenCenter = 320/2; private int yScreenCenter = 240/2; private Vector3d screenPosition = new Vector3d( 0, 0, 20 ); private Vector3d viewAngle = new Vector3d( 0, 90, 180 ); private static final double DEG_TO_RAD = 0.017453292; private double modelScale = 10; CT = Math.cos( DEG_TO_RAD * viewAngle.x ); ST = Math.sin( DEG_TO_RAD * viewAngle.x ); CP = Math.cos( DEG_TO_RAD * viewAngle.y ); SP = Math.sin( DEG_TO_RAD * viewAngle.y ); public void projectPoint( Point3d input, Point3d output ) { double x = screenPosition.x + input.x * CT - input.y * ST; double y = screenPosition.y + input.x * ST * SP + input.y * CT * SP + input.z * CP; double temp = viewAngle.z / (screenPosition.z + input.x * ST * CP + input.y * CT * CP - input.z * SP ); output.x = xScreenCenter + modelScale * temp * x; output.y = yScreenCenter - modelScale * temp * y; output.z = 0; } Let s quickly project some points using this routine to see if it makes sense. The result of running seven 3D points through the projectPoint method is listed in table 2.1. CT: 1 ST: 0 SP: 1 CP: 0 Table 2.1 Sample output from the projectPoint method to project points from 3D-world coordinates to 2D-screen coordinates WX WY WZ SX SY 1 1 0 250 30 -1 1 0 70 30 1 -1 0 250 210 -1 -1 0 70 210 0 0 0 160 120 1 1 1 255 25 -1 -1 1 65 215 15
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services