OsVecMagSquare

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Add exemple)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
|threat_level=
+
|threat_level=ignore
|permissions=
+
|permissions=true
 
|delay=0
 
|delay=0
 
|function_syntax=float osVecMagSquare(vector a)
 
|function_syntax=float osVecMagSquare(vector a)
 
|ossl_example=
 
|ossl_example=
|description=
+
|description= returns the square of the magnitude of vector a.<br>
 +
This saves a square root math operation that is relative slow, when is not needed.<br>
 +
for example to check if magnitude is larger than 10, check if the square is larger than 100
 
|additional_info=
 
|additional_info=
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 
//
 
//
 
// osVecMagSquare Script Example
 
// osVecMagSquare Script Example
 +
// Author: djphil
 
//
 
//
 
+
 
default
 
default
 
{
 
{
 
     state_entry()
 
     state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osVecMagSquare usage.");
 +
    }
 +
 +
    touch_start(integer number)
 
     {
 
     {
 
         vector input = <1.0, 2.0, 3.0>;
 
         vector input = <1.0, 2.0, 3.0>;
         llSay(PUBLIC_CHANNEL, "The square root of the magnitude of " + (string)input + " is " + (string)osVecMagSquare(input) + ".");
+
         llSay(PUBLIC_CHANNEL, "The square root of the magnitude of " + (string)input + " is "  
 +
            + (string)osVecMagSquare(input) + ".");
 
     }
 
     }
 
}
 
}
 
</source>
 
</source>
 
}}
 
}}
'''See Also'''
+
== See Also ==
 +
* [[osVecMagSquare]]
 
* [[osVecDistSquare]]
 
* [[osVecDistSquare]]

Latest revision as of 17:43, 1 June 2021

float osVecMagSquare(vector a)
returns the square of the magnitude of vector a.

This saves a square root math operation that is relative slow, when is not needed.
for example to check if magnitude is larger than 10, check if the square is larger than 100

Threat Level ignore is unknown threat level
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
//
// osVecMagSquare Script Example
// Author: djphil
//
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osVecMagSquare usage.");
    }
 
    touch_start(integer number) 
    {
        vector input = <1.0, 2.0, 3.0>;
        llSay(PUBLIC_CHANNEL, "The square root of the magnitude of " + (string)input + " is " 
            + (string)osVecMagSquare(input) + ".");
    }
}


[edit] See Also

Personal tools
General
About This Wiki