Hey all
I know that quaternions and vectors are almost completely different things, but I need a way around this. Basically, I need to find out the direction a node is pointing with a Vector3. However, getOrientation returns a quaternion, and to my knowledge there is no method for getting a vector.
The purpose of this is find the angle between a vector and the direction the node is pointing. What's happening is that I have a hovercraft that is turning. However, its current velocity is, for example, in direction (1,0,0) and the ship is pointed in (0,0,1). In this case, the ship would be drifting, but I need a way to slow down the ship considerably when it is not facing the direction of its current velocity. The best way I could figure out how to do this was to subtract a certain amount of speed from the current velocity in the opposite direction that the ship is pointed. This 'certain amount of speed' is to be directly proportional to the sine of the angle between the two directions, where the angle has the limits of -pi/2 to pi/2 (ie, if the ship is pointed at 90 degree angle compared to the velocity, it will slow down considerably, but when they are facing the same direction, angle of 0 degrees, the ship will not slow down at all). I need a way to do this, but cannot find a way to get the direction the ship is facing in a vector instead of a quaternion.
Any help is appreciated, whether you come up with a completely new way to do this or if you know/can figure out how to get the vector from the quaternion. Thanks!
[Solved]Getting Vector3 from Quaternion?
-
- Halfling
- Posts: 41
- Joined: Sun May 20, 2007 4:09 am
[Solved]Getting Vector3 from Quaternion?
Last edited by dreadwulgaru on Sat May 29, 2010 10:11 pm, edited 1 time in total.
- wacom
- Gnome
- Posts: 350
- Joined: Sun Feb 10, 2008 2:07 pm
Re: Getting Vector3 from Quaternion?
But there is! Just multiply the quaternion with the forward vector, and you get the direction.dreadwulgaru wrote:Hey all
I know that quaternions and vectors are almost completely different things, but I need a way around this. Basically, I need to find out the direction a node is pointing with a Vector3. However, getOrientation returns a quaternion, and to my knowledge there is no method for getting a vector.
-
- Halfling
- Posts: 41
- Joined: Sun May 20, 2007 4:09 am
Re: Getting Vector3 from Quaternion?
by forward vector do you mean the direction the ship is traveling in or the unit z vector? because I believe I tried that method with the unit z method once and it didn't work after a while. It started out working but after turning a few times it started doing some really weird stuff. I don't really remember specifics, but I can try again and see.
-
- Halfling
- Posts: 41
- Joined: Sun May 20, 2007 4:09 am
Re: Getting Vector3 from Quaternion?
i tried doing what you said with the velocity vector and it worked! thanks 

-
- Gnoblar
- Posts: 1
- Joined: Mon Oct 24, 2011 12:46 pm
Re: [Solved]Getting Vector3 from Quaternion?
Well that was not quite what I was looking for but it pointed me in the right direction,
my script works now so I never have to look at a wall in the way of my person again
well hopefully.
my script works now so I never have to look at a wall in the way of my person again
