
These forums are CLOSED. Please visit the new forums HERE
Need algorithm to make prim point x axis at velocity. |
|
|
Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
|
05-23-2009 16:27
Anyone know the math to do this? I'd greatly appreciate it and i cant seem to find anyone that know.
![]() |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-23-2009 18:47
probably because they can't make sense of the question?
velocity is a measure of RATE of movement, whereas X axis pointing would be rotation around a point. llLookAt will point your prim towards a point regardless of position llRotLookAt will point you prim in a direction regardless of position _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Sharcel Bellic
Greetings, Virtualings!
Join date: 15 Aug 2008
Posts: 127
|
05-23-2009 21:15
I think velocity is a vector that includes both the rate of motion - which is speed - and the direction of the motion.
I read the question as meaning how to make the object's X axis point in the direction of motion. _____________________
http://friendfeed.com/chuckbaggett
"Why do you think developing companies are developing while we stagnate? It’s because people lend small amounts of money to each other in those countries — outside the corrupt banking system. " ~Francine Hardaway http://blog.stealthmode.com/2009/12/whats-coming-next-2010-and-beyond/ |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-23-2009 23:26
Right. So something to the effect of:
CODE
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-24-2009 02:30
Right, or something like:
llSetRot( llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(llGetVel()))); _____________________
From Studio Dora
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
05-24-2009 03:52
this worked pretty well for me..
CODE
It does wobble a bit, and you have to do a little magic at rez time to get said object pointing in the right direction from the word go.. but it does seem to work. _____________________
![]() ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura |
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
Need algorithm to make prim point x axis at velocity.
05-24-2009 05:17
OP asks for the X-axis to point ahead.
Seems to me llLookAt will point the Z-axis ![]() _____________________
From Studio Dora
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-24-2009 08:01
Hewee's will be the most stable, especially across sim bounds, although it doesn't need the current rotation of the object since velocity is in global frame of reference, not local... so this should work fine...
Hewee's rotation variation (tweaked) rotation Velocity2Rotation = llRotBetween( <1.0, 0.0, 0.0>, llGetVel() ); Winter's position variation vector Velocity2Target = llGetPos() + llGetVel(); the second will misbehave when it passes it's mark or if changing sims at anything other than parallel to region axis'. multiplying it by 256 will remove most misbehavior within the same sim. (yes I was having a brain fart earlier... velocity is a measure of rate of movement in a direction, speed is an undirected measure of rate of movement, I'm so used to people saying one to mean the other that I automatically translated it... mistake) _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-24-2009 08:25
OP asks for the X-axis to point ahead. Seems to me llLookAt will point the Z-axis ![]() are you thinking of particles? look at assume the forward axis to be +x _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-24-2009 08:48
are you thinking of particles? look at assume the forward axis to be +x _____________________
From Studio Dora
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-24-2009 09:38
Hewee's will be the most stable, especially across sim bounds, although it doesn't need the current rotation of the object since velocity is in global frame of reference, not local... so this should work fine... Yeah. The reason I included the current rotation was to keep whatever part of the current rotation didn't depend on the direction of velocity. Basically constraining one component of the rotation instead of both (as much as possible). |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-24-2009 09:38
Please take a close look at: http://wiki.secondlife.com/wiki/LlLookAt O.o damn, I was on the page for llRotLookAt when I was working, and assumed they both worked the same... guess not... I don't know the axis swapping formula offhand. _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
05-24-2009 10:39
change the orientation of the base prim so that Z is pointing in the right direction?
Add another prim, or select one that faces correctly. That's what I'd do. Life's too short for complicated geometry. _____________________
![]() ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-24-2009 11:53
change the orientation of the base prim so that Z is pointing in the right direction? Add another prim, or select one that faces correctly. That's what I'd do. Life's too short for complicated geometry. there some odd axis flips in there, that may affect certain builds, but for the most part it treats -x as +z... but getting a rotation that works for it is... mind numbing. just use RotLookAt _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
|
Thankyou!
05-25-2009 17:48
Thanks everyone i figured it out thanks to your help. I will post the solution as soon as sl stops having login issues AGAIN.
![]() |
|
Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
|
Solution
05-26-2009 12:56
rotation VectorToRotation ( vector V )
{ V = llVecNorm( V ); vector UP = < 0.0, 0.0, 1.0 >; return llAxes2Rot(V, UP % V, UP); } |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-26-2009 14:38
rotation VectorToRotation ( vector V ) { V = llVecNorm( V ); vector UP = < 0.0, 0.0, 1.0 >; return llAxes2Rot(V, UP % V, UP); } Iz v.nize! you should add that to the portal (or I can).... but why a function to flatten rotation to the z plane? (although I'm definitely pimping this next time someone asks about keeping their vehicle right side up just feed it <1,0,0>*llGetRot() and toss the normalization line) (rotation flattens inversely to UP's magnitude) PS I knew there was a function I wasn't finding... I need to crosslink Axes2Rot to the others in the Portal EDIT: works for UP = ZERO_VECTOR, but rot between should be more effective (less instructions) _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-26-2009 23:02
Ah, yes. I often use logic that looks quite similar:
CODE
(You may also want to check for the corner case where 'fwd' points straight up or down.) The funny thing is, often people on these boards don't like to think in terms of coordinate basis vectors, so I tend to shy away from that kind of thing when answering questions now. It's thus very surprising to see that this is the solution you came too. Awesome job! ![]() |
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-27-2009 02:18
Let me also congratulate Moira with the simple solution she found
![]() rotation VectorToRotation ( vector V ) { V = llVecNorm( V ); vector UP = < 0.0, 0.0, 1.0 >; return llAxes2Rot(V, UP % V, UP); } (V and UP are not orthogonal if V is pointing up or down) Ah, yes. I often use logic that looks quite similar: CODE
I don't know how much this means in your special case but I have experienced cases where it was crucial! "All three vectors must be mutually orthogonal unit vectors" Reference: http://wiki.secondlife.com/wiki/LlAxes2Rot Edit: attempted solution to Moira's script: CODE There are two solutions, uncomment the one wanted Happy scripting ![]() _____________________
From Studio Dora
|