Difference between revisions of "LlCos"

From Second Life Wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{LSL_Function/angle|theta}}
|sort=Cos|func=llCos
|sort=Cos|func=llCos
|func_id=1|func_sleep=0.0|func_energy=10.0
|func_id=1|func_sleep=0.0|func_energy=10.0
|func_footnote
|func_footnote
|p1_type=float|p1_name=theta|p1_desc=angle expressed in radians.
|p1_type=float|p1_name=theta
|return_type=float
|return_type=float
|return_text=that is the cosine of theta.
|return_text=that is the cosine of {{LSLP|theta}}.
|spec
|spec
|caveats
|caveats=because of IEE754 on single floats, llCos(PI_BY_TWO) returns -4.371139E-8  (hex : 0xB33BBD2E ) and not 0 ; llCos(PI/3.0) returns 0.49999997 ( hex : 0x3EFFFFFF ) and not 0.5
|examples
|examples=<source lang="lsl2">// Touch the object with this script in it to see the cosine of random numbers!
default
{
    touch_start(integer num)
    {
        float r = llFrand(TWO_PI);
        llOwnerSay("The cosine of " + (string)r + " in radians or " + (string)(r * RAD_TO_DEG) + " in degrees is " + (string)llCos(r));
    }
}</source>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 13:31, 14 September 2015

Summary

Function: float llCos( float theta );
0.0 Forced Delay
10.0 Energy

Returns a float that is the cosine of theta.

• float theta angle expressed in radians

Caveats

because of IEE754 on single floats, llCos(PI_BY_TWO) returns -4.371139E-8 (hex : 0xB33BBD2E ) and not 0 ; llCos(PI/3.0) returns 0.49999997 ( hex : 0x3EFFFFFF ) and not 0.5

Examples

// Touch the object with this script in it to see the cosine of random numbers!
default
{
    touch_start(integer num)
    {
        float r = llFrand(TWO_PI);
        llOwnerSay("The cosine of " + (string)r + " in radians or " + (string)(r * RAD_TO_DEG) + " in degrees is " + (string)llCos(r));
    }
}

See Also

Functions

• llSin llAsin sine & inverse Sine
•  llAcos inverse cosine
• llTan llAtan2 tangent & inverse tangent

Deep Notes

Signature

function float llCos( float theta );