Vector2DMixin:GetXY()

From Warcraft Wiki
(Redirected from API Vector2DMixin SetXY)
Jump to navigation Jump to search
These functions are implemented in :GetXY FrameXML/Vector2D.lua and FrameXML/Vector3D.lua.

Defines and returns a vector's Cartesian coordinates.

x, y = vector:GetXY()
x, y, z = vector:GetXYZ()
vector:SetXY(x, y)
vector:SetXYZ(x, y, z)

Parameters

x, y, z
number - Cartesian coordinates.

Details

  • Vector2DMixin uses GetXY() and SetXY().
  • Vector3DMixin uses GetXYZ() and SetXYZ().
  • Despite similarities, these two mixins are not compatible with each other. They must be manually converted or projected by copying coordinate values from one type to another.

Examples

Manually converting a 2D vector to 3D:

local x, y = vector2d:GetXY()
local vector3d = CreateFromMixins(Vector3DMixin)
vector3d:SetXYZ(x, y, 0)

Manually projecting a 3D vector to 2D:

local x, y, z = vector3d:GetXYZ()
local vector2d = CreateFromMixins(Vector2DMixin)
vector3d:SetXY(x, y)

See also

Patch changes

References

 
  1. ^ 2017-03-28, Vector2D.lua, version 7.2.0.23835, near line 65, archived at Townlong-Yak
  2. ^ 2017-03-28, Vector3D.lua, version 7.2.0.23835, near line 72, archived at Townlong-Yak