Dota 2 Workshop Tools/Scripting/API/Global.RotatePosition: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Dota_Lebot push: Updated Page)
(Added example)
Line 1: Line 1:
{{Note | This page is automatically generated.  Any changes may be overwritten}}
[[Category:Dota2Function]]
[[Category:Dota2Function]]
[[Category:Global]]
[[Category:Global]]
Line 5: Line 4:
== Function Description ==
== Function Description ==


''' Vector RotatePosition(Vector ''origin'', QAngle ''rotation'', Vector ''inputVector'') '''


''' Vector RotatePosition(Vector ''Vector_1'', QAngle ''QAngle_2'', Vector ''Vector_3'') '''
Rotates a ''Vector'' around an origin point.


''Rotate a ''Vector'' around a point.''


;Example
<source lang="lua">
-- Converts a vector local to an entity into a world space vector.
--
-- Example: Get a vector 32 units in front of a player.
-- GlobalVectorFromLocal(Vector(32, 0, 0), myPlayerEntity)
--
function GlobalVectorFromLocal(localVec, entity)
-- Here RotatePosition() converts the local space vector into a world space offset from the entity
-- by rotating it by the entity orentation.
local offset = RotatePosition(Vector(0, 0, 0), entity:GetAngles(), localVec)
return entity:GetOrigin() + offset
end
</source>




Line 19: Line 35:
|-
|-
| Vector
| Vector
| Vector_1
| origin
| No Description Set
| The rotation origin
|-
|-
| QAngle
| QAngle
| QAngle_2
| rotation
| No Description Set
| The angles to rotate by
|-
|-
| Vector
| Vector
| Vector_3
| inputVector
| No Description Set
| The vector to rotate
|}
|}


== Returns ==
== Returns ==


''Vector'' - No Description Set
''Vector'' - The rotated vector

Revision as of 03:32, 19 February 2017


Function Description

Vector RotatePosition(Vector origin, QAngle rotation, Vector inputVector)

Rotates a Vector around an origin point.


Example
-- Converts a vector local to an entity into a world space vector.
--
-- Example: Get a vector 32 units in front of a player.
-- GlobalVectorFromLocal(Vector(32, 0, 0), myPlayerEntity)
--
function GlobalVectorFromLocal(localVec, entity)
	
	-- Here RotatePosition() converts the local space vector into a world space offset from the entity
	-- by rotating it by the entity orentation.
	local offset = RotatePosition(Vector(0, 0, 0), entity:GetAngles(), localVec)
	
	return entity:GetOrigin() + offset
	
end


Parameters

Type Name Description
Vector origin The rotation origin
QAngle rotation The angles to rotate by
Vector inputVector The vector to rotate

Returns

Vector - The rotated vector