Dota 2 Workshop Tools/Scripting/API/Global.RotatePosition: Difference between revisions
< Dota 2 Workshop Tools | Scripting | API
Jump to navigation
Jump to search
RoyAwesome (talk | contribs) (Dota_Lebot push: Updated Page) |
Thunder4ik (talk | contribs) m (clean up, added deadend tag) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Dead end|date=January 2024}} | ||
== Function Description == | == Function Description == | ||
''' Vector RotatePosition(Vector ''origin'', QAngle ''rotation'', Vector ''inputVector'') ''' | |||
Rotates a ''Vector'' around an origin 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> | |||
== Parameters == | == Parameters == | ||
Line 19: | Line 32: | ||
|- | |- | ||
| Vector | | Vector | ||
| | | origin | ||
| | | The rotation origin | ||
|- | |- | ||
| QAngle | | QAngle | ||
| | | rotation | ||
| | | The angles to rotate by | ||
|- | |- | ||
| Vector | | Vector | ||
| | | inputVector | ||
| | | The vector to rotate | ||
|} | |} | ||
== Returns == | == Returns == | ||
''Vector'' - | ''Vector'' - The rotated vector | ||
[[Category:Dota2Function]] | |||
[[Category:Global]] |
Latest revision as of 09:58, 21 January 2024

This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024


January 2024
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