Archived

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

no idea :)

This topic is 5624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi.. sorry for my topic, but I have no idea which is the right topic for my question my problem is as below: I have a point and a vector. I want to lock the point to the vector.. If I change the orientation of the vector the orientation of the of the point should be changed the same way. I hope my explanation is clear enough, if not I will explain it again. just let me know..

Share this post


Link to post
Share on other sites
i hate to break it to ya, but points ARE vectors. so, if you have an orientation of a vector, make the point go through the same transformation (which would probably be a rotation in this case)

a2k

Share this post


Link to post
Share on other sites
I see, my explanation was not exact and clear enough...
here is my second try.

I am currently working on a little 3D-Modeller. Now I need to rotate my objects.
If the user select an object a sphere around the object should appear. This sphere should symbolize a trackball. If the user moves the cursor over the sphere, I calculate the vector from the spere origin to the intersection-point. If the user moves his mouse again, I get a second vector.

problem:
I have the vertices of my object and two vectors. I want to know how I have to transform my vertices...

please help...

Share this post


Link to post
Share on other sites
I think I get what you want to do, you want to be able to roll the ball based on your mouse movements?

Well... I think you'd rotate your vertices along the cross product of the two vectors, by the angle between them. I can see that working.


Death of one is a tragedy, death of a million is just a statistic.

[edited by - python_regious on July 24, 2002 7:37:35 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by python_regious
Well... I think you''d rotate your vertices along the cross product of the two vectors, by the angle between them. I can see that working.



good idea... but how I do that, I don''t know how to rotate sth. around a vector. I know it''s possible with quaternions, but I don''t want to use them because I don''t really understand them.. is there another way?

Share this post


Link to post
Share on other sites
//Note: you cannot pass same vector as result and as input.
//Note2: axis has to be normalized for this to work

void RotateVector(D3DVECTOR& v, D3DVECTOR& result, D3DVECTOR& axis, float angle)
{
float c = cosf(angle);
float s = sinf(angle);
float dot = v.x * axis.x + v.y * axis.y + v.z * axis.z;
D3DVECTOR cross(axis.y * v.z - axis.z * v.y,
axis.z * v.x - axis.x * v.z,
axis.x * v.y - axis.y * v.x);
result = c * v + (dot *(1.0f - c)) * axis + s * cross;
}

Of course, if you use quaternions and then convert back to coordinate representation you''ll wind up with the exactly the same expression. The additional nice feature of the above method is that it is easily optimized for vector instructions such as SSE or 3DNow.

M


Share this post


Link to post
Share on other sites
quote:
Original post by a2k
i hate to break it to ya, but points ARE vectors. so, if you have an orientation of a vector, make the point go through the same transformation (which would probably be a rotation in this case)

a2k



Nope.
The definition of a vector says, it has a value (length)
and a direction. A point doesn't have this.
You can obtain a vector that goes from the origin of the point's
coordinate system to the position of the point.
Of course, the values of the point equal the vector's components,
for, the origin is at (0,0,0), but by definition, a point is no vector.


It is now for sure you can throw away your computer

[edited by - UnshavenBastard on July 24, 2002 6:05:46 PM]

Share this post


Link to post
Share on other sites