Skip to main content
gamedev.net
🔒 Locked

vector question

Started by ibelchamber Mar 11, 2005 at 5:17 AM 2 replies 800+ views
Original Post
ibelchamber
ibelchamber
(starter question) What is the best way to do this? I have 3 points represented as vector3s. I want to know where P3 ends up if it is rotated by the same effect as rotating P1 to P2. I think I can see one way: -Get a normal with crossproduct of P1 and P2. -Get a rotation with dotproduct of P1 and P2. -rotate P3 around the normal by the rotation. Doesn't seem very direct, could blow up if there is no difference between P1 and P2? While I'm here, are there any particularly good resources to learn all of these kinds of things? I can find billions of websites with bits of information, maybe it would be better to get a book? Any suggestions for any books? Something biased more towards a practical approach would work best for me. Many Thanks.
mrmrcoleman
mrmrcoleman
There is a book called Computer Graphics Principals and Practise which is pretty much the bible for this sort of stuff, although any good degree level maths text book should cover vectors in enough detail.

Mark Coleman
Zakwayda
Zakwayda
Quote:
While I'm here, are there any particularly good resources to learn all of these kinds of things?
You might check out the book '3D Math Primer for Graphics and Game Development'.
Quote:
I think I can see one way:
-Get a normal with crossproduct of P1 and P2.
-Get a rotation with dotproduct of P1 and P2.
-rotate P3 around the normal by the rotation.

Doesn't seem very direct, could blow up if there is no difference between P1 and P2?
Looks good to me. The methods I can think of to do this pretty much reduce to the same thing. As you noted, the cases where p1 and p2 are colinear (either aligned or opposite) have to be handled separately.

If you're using quaternions, one variation is the 'rotation arc' function described in GPG 1. (Disclaimer: some authors have posted implementations of this function online which they claim to be superior to the GPG version.) In any case, the 'rotation arc' function does gracefully handle the case where p1 and p2 are positively aligned. p1 and p2 negatively aligned still has to be special cased (at least with the GPG version).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.