Jump to content

Dumb Question Concerning Linkset Rotation (SOLVED~! YAY!)


PheebyKatz
 Share

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

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

Recommended Posts

Dear Abby,

I want to make my motorcycle tilt to its own left side when parked. To do this, I'm attempting to get the linkset's rotation (as one would see in the Object tab of the editor), preserve the Y and Z values, change the X value to 350.0 (or -10), and set the linkset's rotation. This, theoretically at least, should simply tilt the linkset -10 degrees on its X axis, thus "parking" the motorcycle.

However, it has issues. If I'm parking while facing East, it works. If I'm facing West when I park, it leans to the right instead.

I tried using llSetPrimitiveParams(), but that rotates the entire bike to face East, and then tilts it. Properly, but yeah.

Whether I use llGetRot, llGetLocalRot, llSetRot, llSetLocalRot, llGetPrimitiveParams, llSetPrimitiveParams, or any combination of these tools, I get the same results; it either spins around to face east and then leans properly, or it leans based on which way it's facing, basically leaning North.

This is the only problem I've run into that I haven't been able to solve by searching, and even the wiki hasn't been of any help. It's probably just me, missing something obvious. If anyone knows what that obvious thing is, please help a poor soul, and in return, I will leave this post as it is, deleting nothing, and also you will have my profoundest gratitude, for what that's worth.

TL;DR: How to simply rotate a linkset -10 degrees on a single axis?

Sincerely,

Baffled In Rotationland

Edited by PheebyKatz
  • Like 1
Link to comment
Share on other sites

5 minutes ago, PheebyKatz said:

TL;DR: How to simply rotate a linkset -10 degrees on a single axis?

Short answer: Set the rotation to rotationRepresentingTenDegreesOnSomeAxis*whateverThePreviousRotaitonWas in that order, so:

llSetRot(llAxisAngle2Rot(<1,0,0>,-10*DEG_TO_RAD)*llGetRot());

from the root prim, or similar with llSetLinkPrimitiveParamsFast(1,[PRIM_ROTATION ...]);

 

Edited by Quistess Alpha
  • Thanks 2
Link to comment
Share on other sites

8 minutes ago, Quistess Alpha said:

Short answer: Set the rotation to rotationRepresentingTenDegreesOnSomeAxis*whateverThePreviousRotaitonWas in that order, so:

llSetRot(llAxisAngle2Rot(<1,0,0>,-10*DEG_TO_RAD)*llGetRot());

from the root prim, or similar with llSetLinkPrimitiveParamsFast(1,[PRIM_ROTATION ...]);

 

I'm working from the root prim, yes. I'll try that, and thanks in advance! Your knowledge and generosity are appreciated more than I can express in mere type.

If this does what I want it to (and considering the source, it should), I'll let you know, and thanks again!

  • Thanks 1
Link to comment
Share on other sites

I know I'm double-posting, but whatever. Bumping to update.

Issue resolved. You fixed my bike. Every solution that didn't solve anything was multiple lines of code, too. This is perfect.

I know it's not much, but I sent you 500L$ as a thank-you. I spent all night fretting over this stupid thing, and you cut it down like nothing.

We truly do have the most awesome people here. Thanks again, you really made my day.

Edited by PheebyKatz
  • Thanks 1
Link to comment
Share on other sites

Longer answer:

Euler-Vectors: the x,y,z values you see in the build menu are a "euler vector" representation of the root prim's rotation. If you move the root prim, everything else in the linkset automatically moves with it without doing anything special.

  • To get the script to tell you what you would otherwise see in the build menu:
    // N.B. llGetRot() and llGetRootRotation() are the same for scripts in the root prim.
    llOwnerSay((string)(RAD_TO_DEG*llRot2Euler(llGetRootRotation())));
  • To rotate the object such that it shows some specific values:
    llSetRootRotation(DEG_TO_RAD*<x,y,z>);

and IMHO those are the only things one 'ought' to do with those numbers. In some very nice cases you can get away with adding a few degrees, but most of the time, that just makes confusing things happen. long story short, the numbers are 'kind of like' pitch,yaw, and roll, but, they're not, and there's really not a good human-brain compatible way to think about them.

Vectors: (I promise this is relevant): While all vectors are 'the same' in that doing math with them is always the same, in a practical sense they often "represent" two rather different things: a "Position Vector" represents some spot in the world that the script cares about (like where something is, or wants to be) and a "Difference Vector" represents some change in position, like a speed/force/acceleration, or just 'one meter up'. The most basic operations with vectors are to add a difference to a position to get a new position (ex. llGetPos()+<0,0,1> is one meter above wherever the object is) or take the difference of two positions to get a difference (ex. llDetectedPos(0)-llGetPos(); is the direction the object would have to go to get to wherever the detected thing is.)

Rotations: Similarly, all rotations are 'the same' mathematically, but they represent two rather different things, an "orientation rotation" represents how something is orientated in 3d space, and a "difference rotation" represents some change in orientation. It's less obvious how to make a valid rotation from just numbers, so we have some useful functions like llAxisAngle2Rot() to make rotations instead of typing them out in numbers directly. Rotations are different than vectors in that instead of using '+' to combine them, you use '*' and combining in a different order means a different thing. the most basic rotation operations are orientation*difference, to change an orientation based on the world's axes (or in the case of a child prim, the axes of the root prim!) , and difference*orientation to change the orientation based on the intrinsic axes of the original orientation. while not nearly as common, you can also take a 'difference' of two orientations orientationB/orientationA to get a difference rotation representing the simplest change to get from orientationA to orientationB.

Maybe that was TMI. . .

 

  • Thanks 1
Link to comment
Share on other sites

Thank you so much. I already understood a lot of that, but others seeking similar answers can learn from it, too.

I was originally using llGetRot to, well, get the rotation, then trying to subtract 10 degrees from the X axis, and then set it to the new rotation, but the math wasn't working in that I couldn't bypass the Y and Z axes, and representing them with zeroes just broke the intended effect.

Being able to single out the X axis itself (or any single axis) and then modify the rotation and apply it, that was my big obstacle.

llAxisAngle2Rot was the missing key. Knowing about this function changes everything.

Oh, and difference*orientation vs orientation*difference is critical knowledge to have. Thanks for that, too.

Edited by PheebyKatz
Link to comment
Share on other sites

1 minute ago, PheebyKatz said:

llAxisAngle2Rot was the missing key. Knowing about this function changes everything.

I've seen llEuler2Rot* used as a substitute for x/y/z axis rotations, but IMHO it's not really correct in a semantic sense, and makes things more confusing if you want to do a diagonal instead.

* so, for example llEuler2Rot(DEG_TO_RAD*<-10,0,0> ); is the same as llAxisAngle2Rot(<1,0,0>,-10*DEG_TO_RAD); but

llEuler2Rot(DEG_TO_RAD*<5,5,0>);  is not the same as llAxisAngle2Rot(<1,1,0>,5*DEG_TO_RAD);

  • Thanks 1
Link to comment
Share on other sites

Yeah, just because you can make something work doesn't make it the best tool. This is true. I was doing 4 lines of figuring using llEuler2Rot in the mix, and nothing was doing anything like it was supposed to by the reckoning I was working with. llAxisAngle2Rot provides a much simpler way. It's obvious just by looking at it how it works, too.

Being able to flag the chosen axis/axes with a 1 or a 0 is useful as all get out. That was my entire issue.

Edited by PheebyKatz
  • Like 1
Link to comment
Share on other sites

  • PheebyKatz changed the title to Dumb Question Concerning Linkset Rotation (SOLVED~! YAY!)
You are about to reply to a thread that has been inactive for 366 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...