Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Find the slope of a euler/rotation in 3D?

Scalar Tardis
SL Scientist/Engineer
Join date: 5 Nov 2005
Posts: 249
04-19-2008 04:14
Trigonometry is not one of my strong points, and I need some help with what is probably a fairly simple problem.


I need to rotate/move a CT scan of my brain around, and it is not going to work to have each slice of the scan as part of a single linked set. I am going to have to keep them as individual prims with enough code in each one so they know where to move and rotate, to keep properly aligned in the stack.

Images of my currently minimally-scripted CT Scan project:

http://img258.imageshack.us/my.php?image=brainviewfrontcenterjo3.jpg
http://img258.imageshack.us/my.php?image=brainviewfrontcloseupxv1.jpg
http://img258.imageshack.us/my.php?image=brainviewfrontleftgy6.jpg


So, I need to rotate and move this stack of 30 paper-thin prims so they are aligned in a straight line on an arbitrary rotation/euler fed from a control panel. The distance between the prims is variable and needs to be part of this math.

Center of axis of rotation <x,y,z>
Rotated using either euler <r,s,t> or rotation <a,b,c,d>
Spacing of "n" meters between each slice.

I assume this involves calculating the "slope" of the vector along which the prims are aligned but I don't know how to do that in 3D.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-19-2008 05:18
You're in the big leagues now, no trig here (ok ok, it's hidden from us by the quaternion in 4D space)

vector base_pos; //base position
rotation base_rot; //base rotation
vector slide_offset_pos; //offset position from base for the slide
rotation slide_offset_rot; //offset rotation from the base for the slide

llSetPos(base_pos + (slide_offset * base_rot));
llSetRot(slide_offset_rot * base_rot);//i may have this reversed, is so try base_rot * slide_offset_rot instead.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
04-19-2008 16:27
lsl wiki, offset rotation.
Chatlan Mapholisto
Registered User
Join date: 7 Dec 2007
Posts: 7
04-19-2008 20:54
Please check llRot2Up().

// code sample //
integer iCh = -123;
float fDistance = 1;
vector vBasePos; = ZERO_VECTOR;
vector vOffsetPos = ZERO_VECTOR;
rotation rBaseRot = ZERO_ROTATION;

rBaseRot = llGetRot();
llSay(iCh, "rot:" + (string)rBaseRot);

vBasePos = llGetPos();
vOffsetPos = llRot2Up(rBaseRot) * fDistance;
llSay(iCh, "pos1:" + (string)(vBasePos + vOffsetPos));
llSay(iCh, "pos2:" + (string)(vBasePos + vOffsetPos * 2));
...