|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
07-24-2007 10:27
I have a script that produces a mobius strip. unfortunately, whenever there is a building block rezzed exactly along one of the primary axis relative to the prim the script is in, it suffers gimbal lock and the piece is off by 180 on both the Y and X axis rotations. I thought I was using rotations to define where pieces should be positioned so that this shouldn't be happening, but it appears not. Any suggestions? From: someone integer iteration=60;//number of prims to build the piece with. float radius=1.5;
default { state_entry() { float i; vector arc; rotation rot; llRegionSay(-24, "die"); llSleep(3); vector my_pos=llGetPos(); for(i= 0; i<= iteration; i+=1) { float calc1=llSin((i/(float)iteration)*2*PI); float calc2=llCos((i/(float)iteration)*2*PI); float calc3=llTan((i/(float)iteration)*2*PI); float rot_calc1=llSin((i/(float)iteration)*3*PI); float rot_calc2=llCos((i/(float)iteration)*3*PI); float rot_calc3=llTan((i/(float)iteration)*3*PI); rot=llRotBetween(<1,0,0>,<rot_calc1,rot_calc2,0>); rot=rot*llRotBetween(<1,0,0>,arc); rot=rot*llGetRot(); arc=<calc2,0,calc1>*radius; llRezAtRoot(block_name,arc*llGetRot()+ my_pos,<0,0,0>,rot,0); llSleep (.1); llSetText((string)arc,<1,1,1>,1); } } }
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
07-25-2007 07:27
Looks like a difficult one. I can't get in-world to test this but if I could I'd see about using llEuler2Rot(<  i/(float)iteration)*2*PI,0,0>  * llEuler2Rot(<0,(i/(float)iteration)*2*PI,0> Or something to that effect. I've not used the llRotBetween much and would prefer to avoid it. Also noticed you use the value "arc" on the line: rot=rot*llRotBetween(<1,0,0>,arc); yet you don't set it until two lines after with: arc=<calc2,0,calc1>*radius;
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
07-25-2007 09:26
From: nand Nerd Also noticed you use the value "arc" on the line: rot=rot*llRotBetween(<1,0,0>,arc); yet you don't set it until two lines after with: arc=<calc2,0,calc1>*radius;
huh. didn't even realize I did that, but it looks like in doing so I accidentally eliminated an incorrect calculation I would have made. I'm still getting the same issue using llEuler2Rot instead of llRotBetween().
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
07-26-2007 00:33
Hmm, what about manually checking if it's a gimbal lock location and setting the value explicitly? i.e. if((i == 0) || (i == (i_max / 4)) ... rot = ...
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Marcel Cromulent
Registered User
Join date: 28 Jan 2007
Posts: 10
|
07-26-2007 02:05
I think that the trouble is that you apply llRotBetween(v,w) to two vectors of opposite direction. There are infinitely man possibilities for rotating v to -v, and no obvious way of chosing one of them.
But you could fo define the rotations you need directly, instead of using llRotBetween. The rotations <,0,0,llSin(PI*i/iterations),llCos(PI*i/iterations)> for i ranging from 0 to iterations would rotate the xy plane once,and <0,llSin(3*PI*i/(iterations*2)),0,llCos(3*PI*i/(iterations*2))> will rotate the xz plane 1.5 times in the same interval .
|