Applet I am currently working on...

Use scroll bar to rotate the cube.


To rotate around x axis:
x1 = x0
y1 = y0 * cos(alpha) - z0 * sin(alpha)
z1 = y0 * sin(alpha) + z0 * cos(alpha)

To rotate around y axis:
x1 = x0 * cos(beta) + z0 * sin(beta)
y1 = y0
z1 = -x0 * sin(beta) + z0 * cos(beta)

To rotate around z axis:
x1 = x0 * cos(gamma) - y0 * sin(gamma)
y1 = x0 * sin(gamma) + y0 * cos(gamma)
z1 = z0

To display depth on screen:
x1 = (a / (b - z0)) * x0
y1 = (a / (b - z0)) * y0

To hide a surface that are not visible using vector:
For (x1 y1, z1), (x2, y2, z2), (x3, y3, z3), calculate x1(y2 - y3) + x2(y3 - y1) + x3(y1 -y2)
If the result is a positive number display it, otherwise do not display


Back to Java Applets' Page