no idea :)

Started by
6 comments, last by Kaesebrot 21 years, 8 months ago
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..
Advertisement
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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...
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]
If at first you don't succeed, redefine success.
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?
//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


thx, this is exactly what I need
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]

This topic is closed to new replies.

Advertisement