No edit summary Tag: WoW API docs |
m (→Example) Tag: WoW API docs |
||
(24 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{wowapitype}} |
{{wowapitype}} |
||
− | + | <font size="3">Source: [https://www.townlong-yak.com/framexml/live/Vector2D.lua SharedXML\Vector2D.lua]</font> |
|
− | == |
+ | ==API== |
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_CreateVector2D]] [https://www.townlong-yak.com/framexml/live/go/CreateVector2D CreateVector2D](<span style="font-size:smaller; color:#ecbc2a">x, y</span>) : <span style="font-size:smaller; color:#4ec9b0">vector</span> - Creates a new vector. |
||
− | * {{api|CreateVector2D(x, y)}} - Creates a new vector with the given coordinates. |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_AreVector2DEqual]] [https://www.townlong-yak.com/framexml/live/go/AreVector2DEqual AreVector2DEqual](<span style="font-size:smaller; color:#ecbc2a">left, right</span>) : <span style="font-size:smaller; color:#4ec9b0">''boolean''</span> - Compares if vectors are equal. |
||
− | * {{api|Vector2DMixin:Clone()}} - Creates a new vector with identical coordinates to the original. |
||
− | == |
+ | ===Methods=== |
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_IsEqualTo]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:IsEqualTo Vector2DMixin:IsEqualTo](<span style="font-size:smaller; color:#ecbc2a">vector</span>) : <span style="font-size:smaller; color:#4ec9b0">''boolean''</span> |
||
− | ; Fundamental |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_GetXY]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:GetXY Vector2DMixin:GetXY](<span style="font-size:smaller; color:#ecbc2a"></span>) : <span style="font-size:smaller; color:#4ec9b0">x, y</span> |
||
− | * {{api|Vector2DMixin:GetXY()}} - Returns the X and Y coordinates |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_SetXY]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:SetXY Vector2DMixin:SetXY](<span style="font-size:smaller; color:#ecbc2a">x, y</span>) |
||
− | * {{api|Vector2DMixin:SetXY(number, number)}} - Defines the X and Y coordinates. |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_ScaleBy]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:ScaleBy Vector2DMixin:ScaleBy](<span style="font-size:smaller; color:#ecbc2a">scalar</span>) |
||
− | * {{api|Vector2DMixin:OnLoad(number, number)}} - Initializes the X and Y coordinates. |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_DivideBy]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:DivideBy Vector2DMixin:DivideBy](<span style="font-size:smaller; color:#ecbc2a">scalar</span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Add]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Add Vector2DMixin:Add](<span style="font-size:smaller; color:#ecbc2a">vector</span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Subtract]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Subtract Vector2DMixin:Subtract](<span style="font-size:smaller; color:#ecbc2a">vector</span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Cross]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Cross Vector2DMixin:Cross](<span style="font-size:smaller; color:#ecbc2a">vector</span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Dot]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Dot Vector2DMixin:Dot](<span style="font-size:smaller; color:#ecbc2a">vector</span>) : <span style="font-size:smaller; color:#4ec9b0">dot</span> |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_IsZero]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:IsZero Vector2DMixin:IsZero](<span style="font-size:smaller; color:#ecbc2a"></span>) : <span style="font-size:smaller; color:#4ec9b0">''boolean''</span> |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_GetLengthSquared]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:GetLengthSquared Vector2DMixin:GetLengthSquared](<span style="font-size:smaller; color:#ecbc2a"></span>) : <span style="font-size:smaller; color:#4ec9b0">lengthSquared</span> |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_GetLength]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:GetLength Vector2DMixin:GetLength](<span style="font-size:smaller; color:#ecbc2a"></span>) : <span style="font-size:smaller; color:#4ec9b0">length</span> |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Normalize]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Normalize Vector2DMixin:Normalize](<span style="font-size:smaller; color:#ecbc2a"></span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_RotateDirection]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:RotateDirection Vector2DMixin:RotateDirection](<span style="font-size:smaller; color:#ecbc2a">rotationRadians</span>) |
||
+ | : [[File:Wowpedia_icon_stamp.png|12px|link=API_Vector2DMixin_Clone]] [https://www.townlong-yak.com/framexml/live/go/Vector2DMixin:Clone Vector2DMixin:Clone](<span style="font-size:smaller; color:#ecbc2a"></span>) : <span style="font-size:smaller; color:#4ec9b0">vector</span> |
||
⚫ | |||
− | ; Manipulation |
||
+ | <syntaxhighlight lang="lua"> |
||
− | * {{api|Vector2DMixin:ScaleBy(number)}} - Multiplies each coordinate by a scalar. |
||
⚫ | |||
− | * {{api|Vector2DMixin:DivideBy(number)}} - Divides each coordinate by a scalar. |
||
⚫ | |||
− | * {{api|Vector2DMixin:Add(Vector2DMixin)}} - Translates the coordinates by the other vector. |
||
− | * {{api|Vector2DMixin:Subtract(Vector2DMixin)}} - Translates the coordinates by the opposite of the other vector. |
||
− | * {{api|Vector2DMixin:Cross(Vector2DMixin)}} - Sets the X coordinate to mimic the Z axis magnitude that would result from calculating the cross-product in 3D space. |
||
− | * {{api|Vector2DMixin:Normalize()}} - Converts to a unit vector by scaling the coordinates so the total length equals 1. |
||
− | * {{api|Vector2DMixin:RotateDirection(number)}} - Rotates the vector counter-clockwise around the Z axis by the number of radians. |
||
⚫ | |||
− | ; Calcuation |
||
⚫ | |||
− | * {{api|Vector2DMixin:IsEqualTo(Vector2DMixin)}} - Returns true if both vectors have equal coordinates. |
||
+ | </syntaxhighlight> |
||
− | * {{api|Vector2DMixin:IsZero()}} - Returns true for the vector (0,0). |
||
− | * {{api|Vector2DMixin:GetLength()}} - Returns the vector's total length or magnitude, independent of direction. |
||
− | * {{api|Vector2DMixin:GetLengthSquared()}} - Returns the dot product of the vector with itself. |
||
− | * {{api|Vector2DMixin:Dot(Vector2DMixin)}} - Returns the dot product of the vector with another. |
||
+ | It's also valid to only pass the <code>x</code> and <code>y</code> fields for API functions that would take a Vector2DMixin object. |
||
⚫ | |||
+ | <syntaxhighlight lang="lua"> |
||
⚫ | |||
+ | /dump C_Map.GetWorldPosFromMapPos(37, {x=0.5, y=1}) |
||
⚫ | |||
+ | </syntaxhighlight> |
||
− | |||
⚫ | |||
⚫ | |||
− | print(foo:GetXY()) <font color="#ecbc2a">-- 16, 13</font> |
||
==Patch changes== |
==Patch changes== |
||
Line 42: | Line 43: | ||
* {{Patch 7.1.0|comment=Vector2D.lua introduced, but without Vector2DMixin.<ref>{{ref FrameXML|Vector2D.lua|7.1.0|22908||20161025}}</ref>}} |
* {{Patch 7.1.0|comment=Vector2D.lua introduced, but without Vector2DMixin.<ref>{{ref FrameXML|Vector2D.lua|7.1.0|22908||20161025}}</ref>}} |
||
− | == |
+ | == See also == |
+ | * [[Vector3DMixin]] |
||
+ | |||
+ | == External links == |
||
<!-- Please read https://wow.gamepedia.com/Wowpedia:External_links_policy before adding new links. --> |
<!-- Please read https://wow.gamepedia.com/Wowpedia:External_links_policy before adding new links. --> |
||
− | {{Elinks-api}} |
+ | {{Elinks-api|t=a|name=CreateVector2D}} |
== References == |
== References == |
Revision as of 20:15, 10 June 2021
Source: SharedXML\Vector2D.lua
API
- CreateVector2D(x, y) : vector - Creates a new vector.
- AreVector2DEqual(left, right) : boolean - Compares if vectors are equal.
Methods
- Vector2DMixin:IsEqualTo(vector) : boolean
- Vector2DMixin:GetXY() : x, y
- Vector2DMixin:SetXY(x, y)
- Vector2DMixin:ScaleBy(scalar)
- Vector2DMixin:DivideBy(scalar)
- Vector2DMixin:Add(vector)
- Vector2DMixin:Subtract(vector)
- Vector2DMixin:Cross(vector)
- Vector2DMixin:Dot(vector) : dot
- Vector2DMixin:IsZero() : boolean
- Vector2DMixin:GetLengthSquared() : lengthSquared
- Vector2DMixin:GetLength() : length
- Vector2DMixin:Normalize()
- Vector2DMixin:RotateDirection(rotationRadians)
- Vector2DMixin:Clone() : vector
Example
local foo = CreateVector2D(12, 5)
local bar = CreateVector2D(2, 3)
foo:Add(bar)
print(foo:GetXY()) -- 14, 8
It's also valid to only pass the x
and y
fields for API functions that would take a Vector2DMixin object.
/dump C_Map.GetWorldPosFromMapPos(37, {x=0.5, y=1})
Patch changes
- Patch 9.0.1 (2020-10-13): Added IsZero() method.[1]
- Patch 8.0.1 (2018-07-17): Added RotateDirection() method.[2]
- Patch 7.2.0 (2017-03-28): Added.[3]
- Patch 7.1.0 (2016-10-25): Vector2D.lua introduced, but without Vector2DMixin.[4]
See also
External links
- GitHub FrameXML, Gethe
- Globe "wut?" Tool, Townlong-Yak
References
- ^ 2020-06-08, Vector2D.lua, version 9.0.1.34714, near line 109, archived at Townlong-Yak
- ^ 2018-07-16, Vector2D.lua, version 8.0.1.27101, near line 122, archived at Townlong-Yak
- ^ 2017-03-28, Vector2D.lua, version 7.2.0.23835, near line 41, archived at Townlong-Yak
- ^ 2016-10-25, Vector2D.lua, version 7.1.0.22908, archived at Townlong-Yak