dcsex.vector
Vector math library.
Contents
- Functions
- Vec2:__init(obj)
- Vec2.new(x, y)
- Vec2:set(x, y)
- Vec2:get()
- Vec2:magnitude()
- Vec2:translate(dx, dy)
- Vec2:rotate(theta)
- Vec3:__init(obj)
- Vec3.new(x, y, z)
- Vec3:set(x, y, z)
- Vec3:get()
- Vec3:magnitude()
- Vec3:translate(dx, dy, dz)
- Vec3:rotZ(theta)
- Vec3:rotX(theta)
- Vec3:rotY(theta)
- Vec3:rotAxis(axis, theta)
- vector
- Fields
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