dcsex.vector

Vector math library.

Contents

  1. Functions
    1. Vec2:__init(obj)
    2. Vec2.new(x, y)
    3. Vec2:set(x, y)
    4. Vec2:get()
    5. Vec2:magnitude()
    6. Vec2:translate(dx, dy)
    7. Vec2:rotate(theta)
    8. Vec3:__init(obj)
    9. Vec3.new(x, y, z)
    10. Vec3:set(x, y, z)
    11. Vec3:get()
    12. Vec3:magnitude()
    13. Vec3:translate(dx, dy, dz)
    14. Vec3:rotZ(theta)
    15. Vec3:rotX(theta)
    16. Vec3:rotY(theta)
    17. Vec3:rotAxis(axis, theta)
  2. vector
    1. _t.bearing(vec1, vec2)
    2. _t.distance(vec1, vec2)
    3. _t.unitvec
    4. _t.dot(U, V)
    5. _t.angle(A, B)
  3. Fields
    1. Vec2.length
    2. Vec3.length
    3. Vec3.rotate

Functions

Vec2:__init(obj)

Create Vec2 object from obj. The constructor never fails and if no coordinate elements are detected all values will be zero.

Parameters

obj
can be a 2d or 3d object of DCS or Vector class origin the constructor will select the correct fields to convert to a normal 2d object based on some DCS particulars.

Vec2.new(x, y)

Create Vec2 object from x and y coordinates. The constructor never fails and if no coordinate elements are detected all values will be zero.

Parameters

x
y

Vec2:set(x, y)

Parameters

x
y

Vec2:get()

Used for passing to DCS functions.

Vec2:magnitude()

Vec2:translate(dx, dy)

Parameters

dx
dy

Vec2:rotate(theta)

Using standard right-hand rule rotation, counter-clockwise for positive values of theta.

Parameters

theta

Vec3:__init(obj)

Create Vec3 object from obj. The constructor never fails and if no coordinate elements are detected all values will be zero.

Parameters

obj
can be a 2d or 3d object of DCS or Vector class origin the constructor will select the correct fields to convert to a normal 3d object based on some DCS particulars.

Vec3.new(x, y, z)

Create Vec3 object from x, y, and z values. The constructor never fails and if no coordinate elements are detected all values will be zero.

Parameters

x
y
z

Vec3:set(x, y, z)

Parameters

x
y
z

Vec3:get()

Used for passing to DCS functions.

Vec3:magnitude()

Vec3:translate(dx, dy, dz)

Parameters

dx
dy
dz

Vec3:rotZ(theta)

Parameters

theta

Vec3:rotX(theta)

Parameters

theta

Vec3:rotY(theta)

Parameters

theta

Vec3:rotAxis(axis, theta)

Parameters

axis
theta

vector

_t.bearing(vec1, vec2)

Parameters

vec1
vec2
optional will be assumed to be zero,zero

Returns

  • bearing in radians

_t.distance(vec1, vec2)

Parameters

vec1
first vector.
vec2
second vector.

Returns

  • distance between vec1 and vec2

_t.unitvec

_t.dot(U, V)

The vectors must be of the same order.

Parameters

U
vector
V
vector

Returns

  • scalar value

_t.angle(A, B)

Parameters

A
B

Returns

  • angle in radians

Fields

Vec2.length

Vec3.length

Vec3.rotate