Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calculating local offset

Catfart Grayson
Registered User
Join date: 16 May 2004
Posts: 264
07-11-2004 01:59
morning,

I'm having trouble with rotations.

What I want to do is find the ground level at a point in the sim, relative to an object. That is:

vector A = llGetPos();
// the object has an random rotation
vector B = target_position;
integer C = llGround(vector D);

vector D is vector B in terms of A's position and rotation. How do I calculate vector D?

I know I have to perform the position transformation

vector E = B - A

I then have to take into account the rotation of the object

rotation AA = llGetRot()

At first, I thought I could do this

vector D = E * (-1 * AA)

But thats not right. I think I've missed a step out, but I cant figure out what.

Anyone help?
Thanks in advance.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-11-2004 02:11
llGround doesn't take into account rotations.

So this code should get you where you want to go:
CODE

groundAtPos(vector position) {
return llGround(position - llGetPos();
}


The reason why it works, is that llGround takes an offset from your current position. This means the vector it works with internally already has llGetPos() added to it. To get a ground height at a specific position, you would subtract llGetPos from your position, because llGetPos is added later on.

(Sorry if this seems a bit off, 4 AM... can't tear myself away from SL :p)
==Chris
Catfart Grayson
Registered User
Join date: 16 May 2004
Posts: 264
07-11-2004 02:22
Thanks Chris,

Looks like I was trying to make it more complicated than needed to.

I shall l give your code a go.