Archived

This topic is now archived and is closed to further replies.

kenki

Question about rotation

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites