Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Distance formula

Tommy Oz
Registered User
Join date: 13 Jan 2005
Posts: 56
02-09-2005 09:46
What is the formula for calculating the the linear distance between two vector points?


Thanks
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
02-09-2005 09:53
From: Tommy Oz
What is the formula for calculating the the linear distance between two vector points?


Thanks


CODE

vector vec1;
vector vec2;
float linear_distance;

linear_distance = llSqrt(((vec1.x - vec2.x)*(vec1.x - vec2.x)) +
((vec1.y - vec2.y)*(vec1.y - vec2.y)) +
((vec1.z - vec2.z)*(vec1.z - vec2.z)));



- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
02-09-2005 10:34
If you, like me, are too lazy to type that in...
CODE
float llVecDist(vector v1, vector v2)
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-09-2005 12:44
Or if you have a grudge against llVecDist you can use...

CODE

llVecMag(v1 - v2)


Not sure why you would...
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Tommy Oz
Registered User
Join date: 13 Jan 2005
Posts: 56
02-09-2005 13:02
PHP Code?

Have I missed something fundamental, like LSL is implemented in PHP and runs PHP code?
Tread Whiplash
Crazy Crafter
Join date: 25 Dec 2004
Posts: 291
Forum bug...
02-09-2005 13:09
No, Tommy -

Its just a forum bug/issue when surrounding code with the markup to make it appear in those little code-boxes. LSL is completely distinct from PHP.

Take care,

--Noel "HB" Wade
(Tread Whiplash)
Tommy Oz
Registered User
Join date: 13 Jan 2005
Posts: 56
02-09-2005 13:44
That's a relief. Damned near had me dumbfounded there. Not that I have anything against PHP, just not for implementing another scripting language.
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
02-10-2005 16:12
From: Ace Cassidy
CODE

vector vec1;
vector vec2;
float linear_distance;

linear_distance = llSqrt(((vec1.x - vec2.x)*(vec1.x - vec2.x)) +
((vec1.y - vec2.y)*(vec1.y - vec2.y)) +
((vec1.z - vec2.z)*(vec1.z - vec2.z)));



- Ace


The-square-of-the-hypotenuse-is-equal-to-the-sum-of-the-squares-of-the-other-two-sides... Ohhhmmmm... :D

Okay, three sides, in this case. I'll stop hijacking now. :)
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"