finding second vector from cosine?

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
JaJDoo
Gnome
Posts: 343
Joined: Wed Feb 04, 2009 9:15 pm
x 5

finding second vector from cosine?

Post by JaJDoo »

i know:
- v1 : the vector
- cos(a) : the cosine of the angle between v1 and v2 (the unknown vector)
- v3 : a vector between the two

how can i find v2 in the simplest way possible?
thought about calculating it using the chord along a tilted unit circle but i got lost somewhere along the way...
some post from somewhere:
"So you basically want to make a car without a steering wheel because you don't know how to drive. I'd say learn how to use pointers"
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Re: finding second vector from cosine?

Post by haffax »

If (and only if) v3 is coplanar to v1 and v2 and if v3 != v1 then you can do this:

Code: Select all

Radian angle = Math::Acos(cos_of_angle_between_v1_and_v2);
Vector3 normal = v1.crossProduct(v3);
Quaternion rot = Quaternion(angle, normal);
Vector3 v2 = rot * v1;
Code is untested and maybe in second line v1 and v3 have to be swapped.
team-pantheon programmer
creators of Rastullahs Lockenpracht
Post Reply