Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calc waypoint

2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
11-11-2009 10:57
Hi,

I have an object at some known location and now I want to move it 10m forward (in the direction it is currently pointing). The object could be rotated, so I don't know which axis I need to change

I looked at llRot2Fwd but I'm not sure if that's what I need. I also just tried this, but the output seems wrong:

CODE

vector p=llGetPos();
llSay(0,"Current Pos: " + (string)p);
p.x+=10;
p*=llGetRot();
llSay(0,"New Pos: " + (string)p);


Output (with object rotated at z=315):

Object: Current Pos: <226.50000, 74.00000, 91.00000>
Object: New Pos: <219.55660, -114.90490, 91.00000>

The X component looks ok, but the Y does not make sense.

Any ideas?

---

Underlying issue: I am trying to calculate a waypoint for a non-physical object. I can move an object from A to B but I am trying to calculate B so that I just keep relative waypoints and calculate absolute coordinates just before I actually move the object.

Thanks -2fast
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-11-2009 11:03
From: 2fast4u Nabob
I have an object at some known location and now I want to move it 10m forward (in the direction it is currently pointing). The object could be rotated, so I don't know which axis I need to change

Rotations either completely make me crazy or they're really, really easy.. This, I think, is one of the easy ones. :)

10m (in .x) in front of the current object is "llGetPos() + (<10.0, 0.0, 0.0> * llGetRot());"

edit: I think what's wrong with your code above is that you're multiplying the current position by the rotation instead of the offset (10m in x) by the rotation.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
11-11-2009 12:56
From: Meade Paravane
... "llGetPos() + (<10.0, 0.0, 0.0> * llGetRot());"...


That did exactly what I need - cool!

Out of curiousness, I moved the 10 from X to Y and had the same result. Does it matter which I use?

Thanks -2fast
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-11-2009 12:58
From: 2fast4u Nabob
Out of curiousness, I moved the 10 from X to Y and had the same result. Does it matter which I use?

Yes. It should very much matter!!

You sure you saw what you thought you saw?
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-12-2009 13:51
If you want to use llRot2Fwd(), I think
CODE
llSetPos(llGetPos()+10.0*llRot2Fwd(llGetRot()));
should do the trick.

That will move the object 10 metres in whatever direction the red arrow is pointing if you examine it in the edit window with the local rather than world ruler mode turned on. Or, to put it another way, whichever way face 2 is pointing if it's a cube
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
11-14-2009 20:08
From: Meade Paravane
Yes. It should very much matter!!


I'll check again - ever since the calculations started working I have been busy on the underlying project :) It's working really well!
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
11-14-2009 20:10
From: Innula Zenovka
That will move the object 10 metres in whatever direction the red arrow is pointing if you examine it in the edit window with the local rather than world ruler mode turned on. Or, to put it another way, whichever way face 2 is pointing if it's a cube


This approach works well too - I think I was probably thinking of this in the first place, but was not able to figure it out. Nice explanation too :)
LisaRaye Chrome
Registered User
Join date: 2 Oct 2009
Posts: 3
11-14-2009 20:18
When Would This Update 1.32.1 Be Available?
I Can Not Logg In World Was Going On?
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-14-2009 22:29
From: LisaRaye Chrome
When Would This Update 1.32.1 Be Available?
I Can Not Logg In World Was Going On?

ummm, wrong thread maybe?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369