Question about rotation
I''m currently working on a program that will allow editing of 3d-models with the mouse. So I was wondering if someone could give advice as to how one knows how much to rotate for a line to point to whare the mouse is (hope this makes sense).
The purpose of this is that one could "grab" the vertex of a line and rotate it around the line''s other vertex. I''m not too sure about rotation-matrices and things, so I really don''t know how to do this.
Also, the program needs to do it with glRotatef. So no just moving the point. I need to know in what way and how much to glRotatef.
Any help is welcome and duly thanked in advance.
when you do it with glrotatef you won t modify the vertex coords
use a 4*4 matrix with homogene coordinates
[1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1]
^^îdentity matrix
have a look at a matrix tutorial and read up matrix multiplication
just multiply the matrix above with [ x y z w]
if you know 3*3 matrices you can replace the 1,1->3,3 fields with the 3*3 matrices
the 4,? could be px py pz 1
if you set the 4,? fields to something else than zero you transform your vertex you multiply with the 4*4 matrix around the point
(px,py,pz)
use a 4*4 matrix with homogene coordinates
[1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1]
^^îdentity matrix
have a look at a matrix tutorial and read up matrix multiplication
just multiply the matrix above with [ x y z w]
if you know 3*3 matrices you can replace the 1,1->3,3 fields with the 3*3 matrices
the 4,? could be px py pz 1
if you set the 4,? fields to something else than zero you transform your vertex you multiply with the 4*4 matrix around the point
(px,py,pz)
http://www.8ung.at/basiror/theironcross.html
Thanks for the advice, friend. I have done as you said (and as I know I should have done ages ago) and read up on matrices. However, I''m still kind of at a loss...
Also, I forgot to mention one thing in the first post: the rotation must only be done so that the point remains on a plane, never outside. This plane is, err... I''ll try to show:
------------ The plane on which rotation occur
(viewed from "above")
------------ The "plane" of the screen
The view will be rotatable though, so I never know what axis(es) to rotate.
I just don''t know how to do what I''m after (even though I now know a bit about how matrices work).
Also, I forgot to mention one thing in the first post: the rotation must only be done so that the point remains on a plane, never outside. This plane is, err... I''ll try to show:
------------ The plane on which rotation occur
(viewed from "above")
------------ The "plane" of the screen
The view will be rotatable though, so I never know what axis(es) to rotate.
I just don''t know how to do what I''m after (even though I now know a bit about how matrices work).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement