Don't click here unless you want to be banned.

LSL Wiki : llVecMag

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
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:
vector corner = <0, 0, 0>;
float distance = llVecMag(llGetPos() - corner);
llSay(0, (string)distance);

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
There is no comment on this page. [Display comments/form]