Jump to content

Linkset Rotation


EnCore Mayne
 Share

You are about to reply to a thread that has been inactive for 4775 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

i have a segment of a sphere (path cut and dimpled) which i would like to rotate around a pivot point. it would act as a door when closed and a ramp when opened. the door would pivot around the red axis prim (fig 1 & 2). 

is there any way to do this with some sort of mathematical calculations?

the only way i've come close to simulating this action is to add a linking prim to the door (root) so that the linked set's coordinates are re-located to the desired pivot point (fig. 3). whether that's necessary with the application of some sort of mathematical, trigonometric, or geometric wizardry i don't know. i'm hoping not since the helper prim would have to be underground. any thoughts?

 

model.jpg

 

simulatedpivotpoint.jpg

pivotprim.jpg

Link to comment
Share on other sites


Void Singer wrote:

position = localPos + (offset - offset * arc) * localRot;

rotation = arc * localRot;

ha, simple for you to say.

i'm absolutely lost.

position = llGetLocalPos() + vector coordinates of hinge - (same X rotation of door represented as type Euler? Rotation? Vector?) X llGetLocalRot();

llSetRot( quaternion rotation X llGetLocalRot() );

i'll do some more reading (till my eyes start to bleed)

 

Link to comment
Share on other sites

arc for a normal door would be something like

arc = llEuler2Rot( <0.0, 0.0, 90.0> * DEG_TO_RAD ); //-- 90deg around the z axis

I'm guessing that your door isn't using the z axis, so I can't say beyond that....

 

you can do it all at once, but it gets ugly because you don't get local position from llGet*PrimitiveParams.

localPos of (link_number) from the root:

llGetLinkPrimitiveParams( link_number, [PRIM_POSITION] ), 0 ) - llGetPos()) / llGetRot();

localPos of (link_number) from (link_number):

llGetLocalPos()

best case scenario, called from the door prim:

llSetPrimitiveParams( [PRIM_POSITION, llGetLocalPos() + (vPosOfs - vPosOfs * vRotArc) * llGetLocalRot(),                      PRIM_ROT_LOCAL, vRotArc * llGetLocalRot() ] );

and you can change the direction of vRotArc each time by using:

vRotArc = ZERO_ROTATION / vRotArc;
Link to comment
Share on other sites


Void Singer wrote:

arc = llEuler2Rot( <0.0, 0.0, 90.0> * DEG_TO_RAD ); //-- 90deg around the z axis

okay, that was the key. simply having that particular snippet is a real boon to what has to be done by lesser human beings without a formal education in mathematics to have the desired degree rotation useful to the computer.

rotations (the most confusing data wrangling/mangling i've encountered) would be easier if i could just input a degree and it would magically occur as it was input inworld. i suppose i should try to bend my head around all the various ways of representing rotations. llOwnerSay() and (string) are real eye openers. so many numbers!

        arc = llEuler2Rot( <0.0, 15.0, 0.0> * DEG_TO_RAD );

        llSetRot( llGetRot() * arc );

so, if i understand for this one instant (i pray i'll remember) the degree vector type has to be changed to radians by multiplying it with DEG_TO_RAD. then, that number, i'm assuming it's a Euler, has to be changed to a rotation by throwing it through llEulerRot(). that result can be put into llSetRot() or a type mismatch will come up.

now all i have to do is get the center of rotation down to the bottom of the door instead of where it rotates now (the center of the spherical segment). the prim's rotation axes are World axes, not local.

so how do i change the rotation pivot point to any point in space? in this case represented by the hinge.

i hope you don't mind my appearing stupid. in this case, i really am!

Link to comment
Share on other sites

figured it out. it can't be done the way i had conceived of it working. i had thought putting a script into the door and having its pivot point changed to where a hinge would go would be the cat's meow. the only way of making the door work correctly is to put the script into the hinge, link the door to it and voila. as far as offsetting the rotation point goes, it always rotates the object from the object's geometric center point (no matter where you put the rotational focus) it won't work as a hinge.

Link to comment
Share on other sites

the "offset" in the above formulas is the distance from the point where your doors center is, to the place you want it to, expressed in the coordinate frame of it's parent at zero rotation....

if your cutout faces a cardinal direction it's easier, but not impossible to do the other way.

you must both move AND rotate for it to work.

Link to comment
Share on other sites

It can be done without adding a real hinge prim. Here is my little script to put into the linked door:

 

vector Hinge;vector Door;rotation CloseRot;float OpenAngle;float Steps = 400.0; // Speed (More means slower and vice-versa.)// llSLPPF() is VERY efficient...integer isOpened = FALSE;uuPivot(integer open){    float step = OpenAngle / Steps;    if (open)    {        float aa = 1.0;        for (; aa <= Steps; aa += 1.0)        {            rotation rot = llEuler2Rot(<0.0, 0.0, step* aa>) * CloseRot;            llSetLinkPrimitiveParamsFast(LINK_THIS,                                         [PRIM_POSITION, Hinge + (Door * rot),                                         PRIM_ROT_LOCAL, rot]);        }    }    else    {        float aa = Steps - 1.0;        for (; aa >= 0.0; aa -= 1.0)        {            rotation rot = llEuler2Rot(<0.0, 0.0, step* aa>) * CloseRot;            llSetLinkPrimitiveParamsFast(LINK_THIS,                                         [PRIM_POSITION, Hinge + (Door * rot),                                         PRIM_ROT_LOCAL, rot]);        }    }}default{    state_entry()    {        // Door: Dimple 0.2 to whatever        vector scale = llGetScale();        Hinge = (<0.0, 0.0, scale.z * -0.5> * llEuler2Rot(<PI_BY_TWO, (0.2 - 0.5) * PI, 0.0>));        // Hinge pos calculated according to dimple and sphere radius.        CloseRot = llGetLocalRot(); // Door must be closed to save/reset the script        Door = (llGetLocalPos() - Hinge) / CloseRot; // Door pos relatively to Hinge pos        OpenAngle = PI_BY_TWO - (PI / 10.0); // PI/2 minus a little something        isOpened = FALSE;    }    touch_start(integer total)    {        isOpened = !isOpened;        uuPivot(isOpened);    }}

 

In not too mathematical words: The script calculates the postion of the hinge using the bottom dimple and the size and rotation of the door, then it calculates the position of the door relative to this virtual hinge. It writes the rotation of the closed door on a little paper. After that, you just need to add a little rotation in the formula to make the door... rotate. This also needs the door to move but llSLPPF() is your friend in here, with the new PRIM_ROT_LOCAL.

(I send you the object in-world.)

 

  • Like 2
Link to comment
Share on other sites


Kaluura Boa wrote:

It can be done without adding a real hinge prim. Here is my little script to put into the linked door:

well, i'll be. so it can be done...just not by me! thanks Kaluura, it works exactly as imagined. kudos to you. as to just how you did it, i'll have to study your script a bit. gimme a week. as it is, my design is sized and oriented differently so it's not just a matter of throwing the script in and voila. oh, and if it's unlinked, you can find the door half a SIM away should you touch it. haha.

argh,  just rotated my design (with hinge prim) off the cardinal point and it goes wonky. that severely limits orienting it inworld. i'll try to adapt my design to your script since yours allows positioning the design any which way one pleases. thanks again Kaluura.

Link to comment
Share on other sites

I am out of town and away from my computer so there's no way I can test this, but I think you can get rid of that wonkiness by just dividing the variable rot where it appears in the two places in Kaluura's function by llGetRot(). You may also need to divide the quantity Hinge + (Door * rot) by llGetRot() as well.  Of course, I could be wrong ..... :smileytongue:

Link to comment
Share on other sites


Rolig Loon wrote:

I am out of town and away from my computer so there's no way I can test this, but I think you can get rid of that wonkiness by just dividing the variable
rot
where it appears in the two places in Kaluura's function by
llGetRot()
. You may also need to divide the quantity
Hinge + (Door * rot)
by
llGetRot()
as well.  Of course, I could be wrong ..... :smileytongue:

no, that was my hinged code Rolig.

        rotational_representation_as_quaternion = llEuler2Rot( human_understood_degree_rotation_as_vector_notation * DEG_TO_RAD );

        llSetRot( llGetRot() * rotational_representation_as_quaternion );

mine goes weird if the design is rotated an infinitesimal amount away from the due East cardinal point. Kaluura's can be rotated throughout all the universe's known points without fail. i can't understand her code. that's not too hard to figure out since i don't have a clue as to what i'm looking at. calculus, trigonometry, euclidian geometry were nice mental exercises to follow back in the day but all that's useless to me now. just when i need it. anywho, i figure it's important to allow for the design to be oriented around the up/down axis so i'll hack away at Kaluura's code to see if i can understand what it's doing right.

Link to comment
Share on other sites


Kaluura Boa wrote:

It can be done without adding a real hinge prim. Here is my little script to put into the linked door:

 
        HingePoint = (<0.0, 0.0, 1/2 door section height> * llEuler2Rot(<1.685, -0.786, 0.0>));

i couldn't get my head around the pi stuff so i hard coded some vector that was close to your variables and observed the resulting phenomenon. then i just tweaked the vector x and y until it was rotating exactly where i wanted it to. i did the same with the OpenAngle and wound up with the float value of 1.59 for a 90 degree angle (which resulted in resting onto the floor height).

if i knew how to describe these problems any better, let alone doing it mathematically, i wouldn't be here. i must say, my education is really paying off being here. thank you to everyone for your help on this. yes, ICDIWY.

oh, i highly recommend checking out Kaluura's home pick. what extraordinarlly stunning examples of how interactive the world can be. dragons! ha! all your gold is mine. that was a real sensory treat.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4775 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...