float llVecMag(vector v)
This function returns the magnitude of
vector v. This magnitude can be multiplied by the result from
llVecNorm(v); (the normalized vector) to give v.
This code will say the distance in metres between the object and the lower southwest corner of the sim:
Question: So what's this actually good for?
Answer: Measuring the length of a vector. Practical uses for this include llWind or passing llGetVel to this to get an object's speed.
//definition
vector VecNorm(vector v) {
return (v / VecMag(v));
}
float VecMag(vector v) {
return llSqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}
float VecDist(vector a, vector b) {
return VecMag(a - b);
}
Compare with
llVecDist, and
llVecNorm.
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions /
Vectors