|
Syphex Odets
Essellian
Join date: 13 Sep 2005
Posts: 16
|
02-25-2006 20:19
Ugh, rotations, the bane of my Second Life. Hopefully someone out there who is more mathematically minded than me can help me out here. It would be much appreciated!
So here's the problem: I want to get the rotation of Object A, relative to object B. Exit object B, enter object C. Now I want to rotate object A relative to object C, as A was to B.
I hope that makes sense. Here's an example, in Eulers (Though I'm not doing any conversions to Eulers in the script so that's not where the problem is). Object A is rotated 90 degrees about the Z axis, and object B is rotated 94 degrees about the Z axis. The difference is therefore -4 degrees. Object C is rotated 137 degrees about the Z axis, so object A needs to end up rotated 133 degrees about the Z axis. When put like that it sounds simple, but in reality every calculation I try comes out wrong.
Thanks.
|
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
02-26-2006 00:37
Syphex, this should do the trick for you. llSetRot( (llGetRot() / BRotation) * CRotation ); Explanation: To convert rotation A from the world's reference, to object B's point of view - divide. To take that relative angle, and "import" it into object C's frame of reference - multiply. But be aware - rotations are not commutative - in other words A*B is not the same as B*A. Just remember that you always multiply or divide the ANGLE by THE FRAME OF REFERENCE. ARotation / BRotation = express A in terms of B's frame of reference Result * CRotation = "import" the result into C's frame.
|
|
Syphex Odets
Essellian
Join date: 13 Sep 2005
Posts: 16
|
02-26-2006 07:04
Thanks very much for your help Ben! Thankyou for the test script you wrote. I don't remember receiving an inventory offer but I found it in my Objects this morning. Must have been where I fell asleep before I logged off. I thought I'd tried this method but I was doing it in a quite a convoluted way and I must have gone wrong somewhere. I'm pretty sure I can get it working now, though I haven't got time to actually rewrite the script at the moment as deadlines loom tomorrow  Anyway, thanks again! Syphex
|