Vector.Rotate
From GMod Wiki
| Function | |
| Syntax | Vector:Rotate( Angle ) |
| Description: | |
| Will rotate the vector around the origin by an angle. | |
| Returns: | nil |
| In Object: | Vector |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Vector.Rotate]Vector.Rotate [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | Rotates myvector around the origin by myangle |
|---|---|
| Used on | |
| Code | local myvector = Vector(-21, -21, -38); local myangle = Angle(90, 90, 90); myvector:Rotate( myangle ); |
| Output | -38, -21, 21 |
| Description | Equation for Angle.Forward |
|---|---|
| Used on | |
| Code |
MyAng = Angle(10,30,50)
myVector = Vector(1,0,0)
myVector:Rotate(MyAng)
print("Angle Forward: " .. tostring(MyAng:Forward()))
print("Another way: " .. tostring(myVector))
|
| Output | Angle Forward: 0.8529 0.4924 -0.1736 Another way: 0.8529 0.4924 -0.1736 |
Additional Notes
- Vector:Rotate() will modify the original vector.