Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calculating pitch/elevation

Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
10-25-2007 03:25
This works but doesn't look right with all the euler conversions...

rotation rot = llGetRot();
vector vec = llRot2Euler(rot);
vec.x = 0;
vec.y = 0;
vector vec2 = llRot2Euler(rot / llEuler2Rot(vec));
float pitch = -vec2.y;

...any ideas for an improvement?
_____________________
http://slurl.com/secondlife/Together
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
10-25-2007 06:24
From: Escort DeFarge
This works but doesn't look right with all the euler conversions...

rotation rot = llGetRot();
vector vec = llRot2Euler(rot);
vec.x = 0;
vec.y = 0;
vector vec2 = llRot2Euler(rot / llEuler2Rot(vec));
float pitch = -vec2.y;

...any ideas for an improvement?

I'm not sure what you're rotating that other vector and such for.. Pitch is just the rotation around the y axis. So all you need is the y value from llRot2Euler(llGetRot()), which will be an angle in radians.

Edit: Nevermind, that's wrong. I think you can use this instead:

vector dir = llRot2Fwd(llGetRot());
float pitch = llAsin(dir.z);
_____________________
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
10-25-2007 07:41
From: Tyken Hightower

vector dir = llRot2Fwd(llGetRot());
float pitch = llAsin(dir.z);

...and you'd be right. Thank you very much! :)
_____________________
http://slurl.com/secondlife/Together