Global/VectorRand

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Function
+
{{Func
| Name = VectorRand
+
|Name=VectorRand
| Namespace = [[Global]]
+
|Parent=Global
| Realm = Shared
+
|Description=Returns a random vector whose components are each between min(inclusive), max(exclusive).
| Origin = Lua
+
|Realm=Shared and Menu
 +
|IsClass=No
 +
|File=lua/includes/util.lua
 +
|Line=94-L98
 
}}
 
}}
 
+
{{Arg
{{Syntax
+
|type=number
| Name = VectorRand
+
|name=min
| Description = Returns a random vector whose components are each between -1 and 1
+
|default=-1
| Returns = {{Return|Vector|randVec}}
+
|desc=Min bound inclusive.
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=max
 +
|default=1
 +
|desc=Max bound exclusive.
 +
}}
 +
{{Ret
 +
|type=Vector
 +
|desc=The random direction vector.
 
}}
 
}}
==Definition==
 
<pre>return Vector( math.Rand(-1.0, 1.0), math.Rand(-1.0, 1.0), math.Rand(-1.0, 1.0) )</pre>
 
 
==Additional Notes==
 
* This will not return unit vectors (Vectors with length = 1), use {{ClassFunction|Vector|GetNormal}} on this
 

Latest revision as of 17:44, 2 July 2019

 VectorRand( )

Contents

Description

Returns a random vector whose components are each between min(inclusive), max(exclusive).

Arguments

number min=-1

Min bound inclusive.

Arguments

number max=1

Max bound exclusive.

Returns

Vector

The random direction vector.
Personal tools
Navigation