Difference between revisions of "LlAcos"

From Second Life Wiki
Jump to navigation Jump to search
m
(10 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL Function
|func_id=172|func_sleep=0.0|func_energy=10.0
|func_id=172|func_sleep=0.0|func_energy=10.0
|func=llAcos|sort=Acos
|func=llAcos|sort=Acos
|return_type=float
|return_type=float
|p1_type=float|p1_name=val|p1_desc=val must fall in the range [-1.0, 1.0]. (-1.0 <{{=}} '''val''' <{{=}} 1.0)
|p1_type=float|p1_name=val|p1_desc=must fall in the range {{Interval|gte=-1.0|center=val|lte=1.0}}
|return_text=that is the arccosine in radians of '''val'''
|p1_hover=must fall in the range {{Interval/Text2|gte=-1.0|center=val|lte=1.0}}
|spec|caveats|func_footnote
|return_text=that is the arccosine in radians of {{LSLP|val}}
|examples=<lsl>// Touch the object with this script in it to see the arccosine of random numbers!
|func_footnote=The returned value is in the range {{Interval|gte=0.0|center=return|lte=[[PI]]|lteh=PI}}{{Interval/Footnote}}
|spec
|caveats
|examples=
<source lang="lsl2">
// This example exercises the full valid range of argument from -1.0 to +1.0
 
default
default
{
{
     touch_start(integer num)
     touch_start(integer num_detected)
     {
     {
         float r = llFrand(2) - 1.0;
         float random = llFrand(2.0) - 1.0;
         llOwnerSay("The arccosine of " + (string)r + " is " + (string)llAcos(r));
 
         llOwnerSay("The arccosine of " + (string)random + " is " + (string)llAcos(random));
     }
     }
}</lsl>
}
</source>
 
<source lang="lsl2">
//An example for the Law of Cosines to calculate any angle of a triangle from 3 known side lengths.
 
default
{
    touch_start(integer num_detected)
    {       
        vector t=< llFrand(9.0)+1.0 , llFrand(9.0)+1.0 , llFrand(9.0)+1.0 >; //the 3 values of this vector are used to set the lengths of 3 sides of a triangle.
 
        float anglexy=llAcos( (t.x*t.x+t.y*t.y-(t.z*t.z)) / ( 2*t.x*t.y) ) //Law Of Cosines
 
        llOwnerSay("Using the Law Of Cosines, the angle of a triangle between side a="+(string)t.x+"and side b="+(string)t.y+"is = "+(string)anglexy+" radians="+(string)(anglexy*RAD_TO_DEG)+"° and that angle is not on side c="+(string)t.z);
    }
}
</source>
|helpers|related
|helpers|related
|also_functions=
|also_functions=
Line 20: Line 44:
{{LSL DefineRow|[[llCos]]||cosine}}
{{LSL DefineRow|[[llCos]]||cosine}}
{{LSL DefineRow|[[llTan]]|[[llAtan2]]|tangent & inverse tangent}}
{{LSL DefineRow|[[llTan]]|[[llAtan2]]|tangent & inverse tangent}}
|also_articles={{LSL DefineRow||{{wikipedia|Inverse_trigonometric_function}}|}}
|also_articles={{LSL DefineRow||{{wikipedia|Inverse trigonometric function}}|}}
|notes
|notes
|cat1=Math/Trigonometry
|cat1=Math/Trigonometry

Revision as of 23:07, 21 January 2015

Summary

Function: float llAcos( float val );

Returns a float that is the arccosine in radians of val

• float val must fall in the range [-1.0, 1.0]

The returned value is in the range [0.0, PI][1]

Examples

//  This example exercises the full valid range of argument from -1.0 to +1.0

default
{
    touch_start(integer num_detected)
    {
        float random = llFrand(2.0) - 1.0;

        llOwnerSay("The arccosine of " + (string)random + " is " + (string)llAcos(random));
    }
}
//An example for the Law of Cosines to calculate any angle of a triangle from 3 known side lengths.

default
{
    touch_start(integer num_detected)
    {        
        vector t=< llFrand(9.0)+1.0 , llFrand(9.0)+1.0 , llFrand(9.0)+1.0 >; //the 3 values of this vector are used to set the lengths of 3 sides of a triangle.

        float anglexy=llAcos( (t.x*t.x+t.y*t.y-(t.z*t.z)) / ( 2*t.x*t.y) ) //Law Of Cosines

        llOwnerSay("Using the Law Of Cosines, the angle of a triangle between side a="+(string)t.x+"and side b="+(string)t.y+"is = "+(string)anglexy+" radians="+(string)(anglexy*RAD_TO_DEG)+"° and that angle is not on side c="+(string)t.z);
    }
}

See Also

Functions

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

Articles

•  "Wikipedia logo"Inverse trigonometric function

Deep Notes

Search JIRA for related Issues

Footnotes

  1. ^ The ranges in this article are written in Interval Notation.

Signature

function float llAcos( float val );