|
Sedalia Kavka
Registered User
Join date: 29 May 2006
Posts: 31
|
10-05-2006 06:36
Hello!
I am working on a project where I am moving something from point A to point B - and that works fine.
However, what I *need* to do is instead of moving all the way from A to B, I need to instead break the journey down into segments of say 'X' length. So for example, if A and B were 20 apart and my segment length (X) is 5, it would take 4 hops to get there.
My problem is, that once I have my destination in mind, I can't seem to find a built-in solution to pick a point in between to move to. I know I could sit down and work the math, but I have a sneaking suspicion there is a handy way to do what I need through a combination of LL functions.
So, given a starting point, does anyone know a way to pick a point X length away in a specifc direction? By virtue of the project I am working on, there will be an axis of the object facing the final location, in case that is useful. I also have the rotation of the object obviously.
It is because of all the pieces of data that I know, that I am certain there is an easier way to get my intermediate point(s) than by working out all the math by hand. I'm sure I am just missing an easy combo of functions hehe.
Thank you!!
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-05-2006 11:50
It's easy, well easy-ish.
Here's some maths:
Let point A be a=<x1, y1, z1>, point B be b=<x2, y2, z2>
The total vector A -> B is b-a
unit step along this vector is b-a/mag(b-a)
In lsl terms... b-a works just fine. mag(b-a) is llVecDist(a, b)
That will let you work out steps 1m at a time. Because it's still a vector quantity (a vector divided by a scalar), you can multiply by the desired length of each step... e.g. vector move = (b-a)/llVecDist(a, b) * 5.0;
then it's just llSetPos(llGetPos()+move); or the equivalent for physical movement.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-05-2006 14:33
Sedalia take a look at the WarpPos page in the wiki. That is exactly what is does. It is divides the distance between position where you and and the one you need to get to into "hops": http://www.lslwiki.com/lslwiki/wakka.php?wakka=LibraryWarpPosThe math involved is shown clearly there.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Sedalia Kavka
Registered User
Join date: 29 May 2006
Posts: 31
|
10-06-2006 05:18
Thanks to both of you! I couldn't get either one to work the way I wanted - but by using pieces from each method, it works!! Thank you! 
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
10-07-2006 09:38
From: Eloise Pasteur unit step along this vector is b-a/mag(b-a) In lsl terms... b-a works just fine. mag(b-a) is llVecDist(a, b) In LSL terms, unit step along this vector is llVecNorm(b-a).
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-07-2006 12:06
D'Oh, don't use positioning stuff like this often, but yes, you're right.
If I ever do it, I'll hope I remember it!
|