Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vector/Math Help Needed

Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
10-06-2005 22:50
Okay, I'm having a hard time wrapping my head around something and I hope you guys who are better at working with vectors can help.

Take a look at this diagram

Say that "S" represents the start vector coordinates and "E" the end vector coordinates. I know I can use llVecDist() to determine how far S is from E.

I'd like "M" to represent a position along that path that is 300 meters before you reach the end. Keeping in mind that the end could be in any direction from the start, how do I calculate what the coordinates of "M" are?
Archanox Underthorn
Registered User
Join date: 20 May 2003
Posts: 168
10-06-2005 23:39
Well I'm not extremely well versed in vector math, so if someone who sees this knows better please tell me I'm wrong. If you use llVecNorm on your final destination vector, it will return a vector that represents its direction. Now if you were to multiply that vector by llVecMag it would return your final destination vector again. However since you want 300m before that, try doing llVecNorm(dest) * (llVecMag(dest) - 300). Let me know if that helped at all :P
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
10-06-2005 23:41
CODE
M = E - 300.0 * llVecNorm(E - S);
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Online Doesburg
absurd hero
Join date: 6 Jul 2005
Posts: 53
10-07-2005 06:50
Not sure if this is relevant, but keep in mind that with this formula, M will end up farther away from E than S, if the distance between S and E is less than 300.
_____________________
"The evil that is in the world almost always comes of ignorance, and good intentions may do as much harm as malevolence if they lack understanding." - Albert Camus