Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Ever wonder how to find a mid-vector between 2 coordinates? I designed a way!

Khalek Trescothick
Registered Idiot
Join date: 28 Dec 2005
Posts: 10
06-23-2006 17:44
Here is the way I figured out how to get a midpoint between two vectors. Since the Lindens only have a way to find Distance, I figured id share it with you.
CODE

vector llFindMidpoint(vector v1, vector v2)
{
float x1 = v1.x;
float y1 = v1.y;
float z1 = v1.z;
float x2 = v2.x;
float y2 = v2.y;
float z2 = v2.z;
float mid_x = (x1+x2)/2;
float mid_y = (y1+y2)/2;
float mid_z = (z1+z2)/2;
vector ret = <mid_x,mid_y,mid_z>;
return ret;
}

Have fun
_____________________
K. Trescothick
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
06-23-2006 18:19
Or:

return (v1 + v2) * 0.5;
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG