Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
Tag: WoW API docs
Tag: WoW API docs
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{wowapitype}}
 
{{wowapitype}}
<font size="3">Source: [https://www.townlong-yak.com/framexml/live/Vector2D.lua FrameXML/Vector2D.lua]</font>
+
<font size="3">Source: [https://www.townlong-yak.com/framexml/live/Vector2D.lua SharedXML\Vector2D.lua]</font>
   
== Instantiation ==
+
==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.
 
   
== Methods ==
+
===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>
* {{api|Vector2DMixin:Add(Vector2DMixin)}} - Translates the vector by another.
 
  +
: [[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:Cross(Vector2DMixin)}} - Mimics a 3D cross product, computing its magnitude and then applying this value to the X coordinate.
 
  +
: [[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:DivideBy(number)}} - Divides each coordinate by a scalar.
 
  +
: [[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:Dot(Vector2DMixin)}} - Returns the dot product of the vector with another.
 
  +
: [[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>)
* {{api|Vector2DMixin:GetLength()}} - Returns the vector's total length or magnitude, independent of direction.
 
  +
: [[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>)
* {{api|Vector2DMixin:GetLengthSquared()}} - Returns the dot product of the vector with itself.
 
  +
: [[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>)
* {{api|Vector2DMixin:GetXY()}} - Returns the X and Y coordinates.
 
  +
: [[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>)
* {{api|Vector2DMixin:IsEqualTo(Vector2DMixin)}} - Returns true if both vectors have equal coordinates.
 
  +
: [[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>
* {{api|Vector2DMixin:IsZero()}} - Returns true for the vector (0,0).
 
  +
: [[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>
* {{api|Vector2DMixin:Normalize()}} - Divides each coordinate by the vector's total length, producing a unit vector in the same direction.
 
  +
: [[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>
* {{api|Vector2DMixin:RotateDirection(number)}} - Rotates the vector counter-clockwise by a number of radians.
 
  +
: [[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>
* {{api|Vector2DMixin:ScaleBy(number)}} - Multiplies each coordinate by a scalar.
 
  +
: [[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>)
* {{api|Vector2DMixin:SetXY(number, number)}} - Defines the X and Y coordinates.
 
  +
: [[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>)
* {{api|Vector2DMixin:Subtract(Vector2DMixin)}} - Translates the vector by the opposite of another.
 
  +
: [[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>
   
== Example ==
+
==Example==
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
local foo = CreateVector2D(12, 5)
 
local foo = CreateVector2D(12, 5)
Line 31: Line 32:
 
</syntaxhighlight>
 
</syntaxhighlight>
   
  +
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.
== Patch changes ==
 
  +
<syntaxhighlight lang="lua">
  +
/dump C_Map.GetWorldPosFromMapPos(37, {x=0.5, y=1})
  +
</syntaxhighlight>
  +
 
==Patch changes==
 
* {{Patch 9.0.1|note=Added IsZero() method.<ref>{{ref FrameXML|Vector2D.lua|9.0.1|34714|109|20200608}}</ref>}}
 
* {{Patch 9.0.1|note=Added IsZero() method.<ref>{{ref FrameXML|Vector2D.lua|9.0.1|34714|109|20200608}}</ref>}}
 
* {{Patch 8.0.1|note=Added RotateDirection() method.<ref>{{ref FrameXML|Vector2D.lua|8.0.1|27101|122|20180716}}</ref>}}
 
* {{Patch 8.0.1|note=Added RotateDirection() method.<ref>{{ref FrameXML|Vector2D.lua|8.0.1|27101|122|20180716}}</ref>}}
Line 42: Line 48:
 
== External links ==
 
== 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

Wowpedia icon stamp CreateVector2D(x, y) : vector - Creates a new vector.
Wowpedia icon stamp AreVector2DEqual(left, right) : boolean - Compares if vectors are equal.

Methods

Wowpedia icon stamp Vector2DMixin:IsEqualTo(vector) : boolean
Wowpedia icon stamp Vector2DMixin:GetXY() : x, y
Wowpedia icon stamp Vector2DMixin:SetXY(x, y)
Wowpedia icon stamp Vector2DMixin:ScaleBy(scalar)
Wowpedia icon stamp Vector2DMixin:DivideBy(scalar)
Wowpedia icon stamp Vector2DMixin:Add(vector)
Wowpedia icon stamp Vector2DMixin:Subtract(vector)
Wowpedia icon stamp Vector2DMixin:Cross(vector)
Wowpedia icon stamp Vector2DMixin:Dot(vector) : dot
Wowpedia icon stamp Vector2DMixin:IsZero() : boolean
Wowpedia icon stamp Vector2DMixin:GetLengthSquared() : lengthSquared
Wowpedia icon stamp Vector2DMixin:GetLength() : length
Wowpedia icon stamp Vector2DMixin:Normalize()
Wowpedia icon stamp Vector2DMixin:RotateDirection(rotationRadians)
Wowpedia icon stamp 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

See also

External links

References

 
  1. ^ 2020-06-08, Vector2D.lua, version 9.0.1.34714, near line 109, archived at Townlong-Yak
  2. ^ 2018-07-16, Vector2D.lua, version 8.0.1.27101, near line 122, archived at Townlong-Yak
  3. ^ 2017-03-28, Vector2D.lua, version 7.2.0.23835, near line 41, archived at Townlong-Yak
  4. ^ 2016-10-25, Vector2D.lua, version 7.1.0.22908, archived at Townlong-Yak