llAcos
float llAcos(float Value)Returns the arc-cosine of Value, in radians.
Parameters
-
Value(float) - A floating-point value.
- Triggers a Math Error for complex results if not compiled in Mono.
Examples
Section titled “Examples”Basic Example - Valid Range
Section titled “Basic Example - Valid Range”// 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)); }}Law of Cosines - Triangle Angle Calculation
Section titled “Law of Cosines - Triangle Angle Calculation”//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); }}