I have done this two ways. One of which allows the full rotation in x y and z.
The simple method (no rotation) can be created by simply using a function to translate 3D coordinates to 2D
For example
The other method uses simple linear algebra (namely the rotion matrix.Code:Screen_X = 0.5 * x + 0.5 * z Screen_Y = -0.3 * x + 0.3 * z + y
note that the rotations are about the origin in this case. When displaying you might need to shift the image to have it positioned nicely in a picture box.Code:Dim Old_X as Integer Dim Old_Y as Integer Dim Old_Z as integer Dim Theta_X as single, Theta_Y as single, Theta_Z as single Theta_X = 'x angle here Theta_Y = 'y angle here Theta_Z = 'z angle here 'rotate around the x=axis Old_Y = y Old_Z = z y = Cos(Theta_X) * Old_Y + Sin(Theta_X) * Old_Z z = -Sin(Theta_X) * Old_Y + Cos(Theta_X) * Old_Z 'rotate around the y=axis Old_X = x Old_Z = z x = Cos(Theta_Y) * Old_X + Sin(Theta_Y) * Old_Z z = Sin(Theta_Y) * Old_X + Cos(Theta_Y) * Old_Z 'rotate around the z=axis Old_X = x - centerX Old_Y = y - centerY x = Cos(Theta_Z) * Old_X+ Sin(Theta_Z) * Old_Y y = Sin(Theta_Z) * Old_X + Cos(Theta_Z) * Old_Y




Reply With Quote