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

LSL Wiki : ExampleRotToVecAngle

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
These functions will let you convert rotations into a vector (axis) and the angle the vector is rotated by (the rotation is perpendicular to the vector). The final function lets you convert back.

vector getVecFromRot(rotation r)
{//llRot2Axis
    vector v = <r.x, r.y, r.z>;
    if(v)//Is the vector a zero vector?
        return llVecNorm(v);//not a zero vector, so normalize it
    return v;//vector was zero.
}

float getAngleFromRot(rotation r)
{//llRot2Angle
    return 2 * llAcos(r.s / llSqrt(r.x * r.x + r.y * r.y + r.z * r.z + r.s * r.s));
}

rotation getRotFromVecAngle(vector v, float a)
{//llAxisAngle2Rot, not normalized
    return <v.x, v.y, v.z, 1 / llTan(a / 2)>;
}

I optimized the functions a bit. These are examples how the Axis-Angle functions work. --BW
There is one comment on this page. [Display comments/form]