Homework II
Cube Moving in Three Dimension
1.0
In this assignment, we do 3D-to-2D transformations to view a 3D object through our screen.
1.1 Source codes description :
>1.1.1 PrjtingObj.java ----- classes of 3D objects(points, planes...) and all projection functions.
(1) Function 'ProjectToPlane', Projects a 3D point to a point on view plane.
(2) Function 'VPlaneToScreen', Transform set of 3D points on a plane to set of 2D points.
(3) Function 'ScreenTrans', Transform set of points on 2D to a window with given size.
>1.1.2 Matrix3D.java ----- all transformation functions: Translate, Rotate, Scale and some necessary operations for matrix.
>1.1.3 ThreeD.java ----- I/O processing and events handler.
1.2 Idea :
>1.2.1 First, we assume there is a view plane L and a view point V. For each object in 3 dimension, we just transform each (significant) point P of this object to view plane L by computing the intersection of line VP and plane L. The equation is:
P'(after projecting) = V + t x (P-V) &&
P' belongs to L
Now each three dimension point can be transformed to 2 dimension point if the origin and identity of this plane has been assigned. To describe in detail:
new point Q.x = (reference vector V) dotproduct (identity vector)
new point Q.y = (+/-) norm_of { (reference vector V) crossproduct (identity vector) } (*)
(*) we need to decide the sign by checking direction of the norm vector
The last step and the easiest step is we need to do a approapriate transformation to let all points located in a good place in the display window.
>1.2.2 The transformations for matrix are based on the Graphics's Textbook by Foley, van Dam, Feiner and Hughes.
>1.2.3 I/O is based on the code of 'ThreeD.java'.
2.0
Welcome to Program Demo, you can use either mouse or keyboard to move the object.