Difference between revisions of "LlAxisAngle2Rot"

From Second Life Wiki
Jump to navigation Jump to search
m (Fix for alphabetical order in Functions list)
m
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func=llAxisAngle2Rot
|func=llAxisAngle2Rot
|sort=AxisAngle2Rot
|func_id=169|func_sleep=0.0|func_energy=10.0
|func_id=169|func_sleep=0.0|func_energy=10.0
|return_type=rotation
|return_type=rotation
Line 7: Line 6:
|p2_type=float|p2_name=angle|p2_desc=expressed in radians.
|p2_type=float|p2_name=angle|p2_desc=expressed in radians.
|return_text=that is a generated '''angle''' about '''axis'''
|return_text=that is a generated '''angle''' about '''axis'''
|func_footnote='''axis''' should be {{LSLG|llVecNorm|normalized}}.
|func_footnote=
'''axis''' need not be [[llVecNorm|normalized]], only the direction is important.                     
 
'''angle''' need to be between the value 0<angle<PI (higher values than PI lead to 2*PI-angle)
, because a rotation is not really a rotation (it is more of a rigid motion/mirroring)
,the final destination is the rotation.  
(in other words: it doesn't matter wether you rotate left by 90 degrees or right by 270 degrees it will return the same rotation)
|spec
|spec
|caveats
|caveats
|examples
|examples=<source lang="lsl2">default
{
    state_entry()
    {
        vector axis = <0.0, 0.0, 1.0>;
        float angle = 90.0 * DEG_TO_RAD;
        rotation rot = llAxisAngle2Rot(axis, angle);
        vector euler = llRot2Euler(rot) * RAD_TO_DEG;
 
        llOwnerSay((string) euler);
        //Says <0.0, 0.0, 90.0> since it is rotating 90 degrees on the Z axis caused by the 1.0 placed in the Z vector spot.
    }
}</source>
 
|helpers
|helpers
|related
|also_functions=
{{LSL DefineRow||[[llRot2Angle]]|}}
{{LSL DefineRow||[[llRot2Axis]]|}}
|also_events
|also_articles
|also
|also
|notes
|notes
|cat1=Math/3D
|cat1=Math/3D
|cat2
|cat2=Rotation
|cat3
|cat3
|cat4
|cat4
|deepnotes=<source lang="lsl2">rotation llAxisAngle2Rot( vector axis, float angle )
{
    axis = llVecNorm( axis ) * llSin( angle/2 );
    return <axis.x, axis.y, axis.z, llCos( angle/2 )>;
}</source>
}}
}}

Latest revision as of 22:40, 21 January 2015

Summary

Function: rotation llAxisAngle2Rot( vector axis, float angle );
0.0 Forced Delay
10.0 Energy

Returns a rotation that is a generated angle about axis

• vector axis
• float angle expressed in radians.

axis need not be normalized, only the direction is important.

angle need to be between the value 0<angle<PI (higher values than PI lead to 2*PI-angle) , because a rotation is not really a rotation (it is more of a rigid motion/mirroring) ,the final destination is the rotation. (in other words: it doesn't matter wether you rotate left by 90 degrees or right by 270 degrees it will return the same rotation)

Examples

default
{
    state_entry()
    {
        vector axis = <0.0, 0.0, 1.0>;
        float angle = 90.0 * DEG_TO_RAD;
        rotation rot = llAxisAngle2Rot(axis, angle);
        vector euler = llRot2Euler(rot) * RAD_TO_DEG;

        llOwnerSay((string) euler);
        //Says <0.0, 0.0, 90.0> since it is rotating 90 degrees on the Z axis caused by the 1.0 placed in the Z vector spot. 
    }
}

See Also

Functions

•  llRot2Angle
•  llRot2Axis

Deep Notes

rotation llAxisAngle2Rot( vector axis, float angle )
{
    axis = llVecNorm( axis ) * llSin( angle/2 );
    return <axis.x, axis.y, axis.z, llCos( angle/2 )>;
}

Signature

function rotation llAxisAngle2Rot( vector axis, float angle );