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...
finding second vector from cosine?
- JaJDoo
- Gnome
- Posts: 343
- Joined: Wed Feb 04, 2009 9:15 pm
- x 5
finding second vector from cosine?
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"
"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"
- haffax
- 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?
If (and only if) v3 is coplanar to v1 and v2 and if v3 != v1 then you can do this:
Code is untested and maybe in second line v1 and v3 have to be swapped.
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;