|
-
July 3rd, 2011, 03:24 PM
#1
3d camera rotation- how to obtain?
Hi,
Since a while I'm interested in 3d graphics programming, but my aim is to learn how to make one's own 3d engine, I really want to understand the math behind it .
I've created a camera which works quite well, the only problem i have is how to obtain proper rotation of it. When i rotate it about a Z axis then X and Y rotations are following the global axises (not the rotated X Y axises of the camera). When I try to do it in the reverse order, then I get false result with Z axis.
My question is : how to rotate camera around its own coordinates, not the word coordinates?
I'll appreciate any help,
best regards , gorgh
-
July 22nd, 2011, 07:36 AM
#2
Re: 3d camera rotation- how to obtain?
wow, cool.
As a programer, I suggest you grab some open sources at first.
Here's a list of them http://www.becoding.com/source/3d+engine/.
-
July 22nd, 2011, 01:31 PM
#3
Re: 3d camera rotation- how to obtain?
There are numerous ways to represent rotations. One common way for computer graphics is via a rotation matrix. A rotation matrix is a matrix A such that A*[1,0,0] gives the camera's x axis unit vector, A*[0,1,0] gives the camera's y axis, and A*[0,0,1] gives the camera's z axis unit vector.
Rotation matrices have many nice properties. If you want the inverse of a rotation matrix, you can just take the transpose. If you want to do one rotation followed by another, you can just multiply the two matrices (composition). With these two properties, you can rotate a camera from any coordinate system to any other by first finding the rotation A, as above, which takes the coordinate basis it to its current axis; and then finding another rotation B, which takes the coordinate basis to the new axis. Then the rotation from the current axis to the new axis is B*A^T: first rotate back to the coordinate basis, and then to the new axis. (You need to read the multiplication right-to-left.)
Unfortunately, rotation matrices can occasionally develop singularities known as gimbal lock. For numerically stable rotations without this problem, you can use quaternions. Be warned, quaternions are not at all intuitive and may appear mathematically intimidating at first glance, but they work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|