. I want to know what rotation I need to look from point A to point B, assuming zero rotation to begin with. Anyone know how to do this or am I misreading one of the rotation functions on the wiki?These forums are CLOSED. Please visit the new forums HERE
Figuring Rotation Between Two Points? |
|
|
Feynt Mistral
Registered User
Join date: 24 Sep 2005
Posts: 551
|
03-24-2006 02:57
Say I've got point A (we'll say <3,3,3> ) and point B (<2,3, 1>
. I want to know what rotation I need to look from point A to point B, assuming zero rotation to begin with. Anyone know how to do this or am I misreading one of the rotation functions on the wiki?_____________________
I dream of a better tomorrow in SL!
You should too. Visit, vote, voice opinions. Support CSG! Tell LL how much it would mean to subtract one prim from another! Prim Animation! Stop by and say something about it, show your support! |
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
03-24-2006 03:05
Okay, if you're at A, you want to point yourself towards B - in other words, pointing in the vector (B-A). Presumably you want to have your forward vector pointing in that direction.
Therefore you work out the rotation between your forward vector and (B-A). To find out what that is, I think you want: CODE llRotBetween(llRot2Fwd(llGetRot()), llVecNorm(vecB - vecA)) where vecB and vecA are the positions of B and A respectively. Disclaimer: I am rubbish at rotations. |
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
03-24-2006 03:42
CODE llRotBetween(llRot2Fwd(llGetRot()), llVecNorm(vecB - vecA)) CODE llRotBetween(<0,0,1>, llVecNorm(vecB - vecA))(if you want to llSetRot(that_thing) and have the top (say) point at B). _____________________
-Seifert Surface
2G!tGLf 2nLt9cG |
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
03-24-2006 04:01
Yeah, if you want to use llSetRot you'll want the absolute rotation, i.e. from the axis you want to point at zero rotation, rather than the one relative to your current facing.
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
03-24-2006 09:52
Also consider llLookAt(), which will rotate your object to look at a point. Works on physical and nonphysical objects.
|
|
Feynt Mistral
Registered User
Join date: 24 Sep 2005
Posts: 551
|
03-24-2006 17:12
I wanted to know because I'm making a camera that simulates the Resident Evil style. It fixes the camera's location at a nearby prim that's above your waist height. That's all well and good, and it does that, but with thick objects that have nearby prims your view can be obstructed somewhat. So I was thinking of shifting the camera's position 2m out from the center of the prim towards the avatar. I have an equation to do such an adjustment, but I need to know the rotation necessary to point from the prim's location to the player's position.
_____________________
I dream of a better tomorrow in SL!
You should too. Visit, vote, voice opinions. Support CSG! Tell LL how much it would mean to subtract one prim from another! Prim Animation! Stop by and say something about it, show your support! |