Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

The Opposite Direction

Luke Poplin
Registered User
Join date: 2 Feb 2007
Posts: 32
01-14-2008 09:52
I need a little help determining the opposite direction an avatar is facing. I can determine the vector the avatar is facing, but how to I negate that or get the "backward facing" vector?

Any help would be great.

Thanks!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-14-2008 09:58
vector forward = ...;
vector backward = -forward.
Luke Poplin
Registered User
Join date: 2 Feb 2007
Posts: 32
01-14-2008 10:00
That simple? I'm going to go soak my head now.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-14-2008 12:52
No worries. It being that simple is GOOD news. Not everything that should be so simple is, by a long shot. :-)
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
01-14-2008 13:08
It depends on what you mean by the vector you are facing.

If you mean a point in space that your X-axis is pointing at, then back = -forward will work, I think.

But if you mean a vecotr that is an Euler-rotation, I don't think so. In that case, *if* you are standing vertically, you only want to change your rotation around the Z axis by 180 degrees, which is pi radians.

back = < for.x, for.y, PI+for.z>

think.

Lastly, Directions in SL are often stored as rotations, not vectors.
_____________________
So many monkeys, so little Shakespeare.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-15-2008 02:20
reversing a vector on the z axis you want to add (or subtract) 180 degrees if in degrees or pi as stated above if in radians (no need to covert) NOT just negate it....

you can however reverse a quaternion rotation simply by negating the last part before using it
rotation.s *= -1; //-- same as rot.s = rot.s * -1
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -