VR-Forces 5.1.1 Lua Function Documentation

Vector3D

(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)

A Vector3D is a vector in earth-relative coordinates, e.g. east-north or heading-range. Its direction in a fixed coordinate system (such as geocentric) depends on where on the earth it is attached (like topocentric coordinates). A Vector3D is not strictly a vector because it wraps around the curvature of the earth; e.g a Vector3D with no inclination is a curve that is parallel to the earth's surface. The "earth's surface" is the WGS84 ellipsoidal model.

Function List

Vector3D (north, east, down) Constructor for Vector3D.
addOffset (offsetVector) Creates a vector that is the sum of this vector and the given offset vector.
addVector3D (vector) Creates a vector that is the sum of this and the given vector.
crossVector3D (vector) Creates a vector that is the cross product of this vector with the given vector.
dotVector3D (vector) Computes the dot product of this vector with the given one.
getBearing () Angle in radians clockwise of the vector from north
getDown () Length in meters of downward-pointing component of vector
getEast () Length in meters of east-pointing component of vector
getInclination () Angle in radians of vector from horizontal
getNegated () Creates a vector that is the negation of this vector, i.e.
getNorth () Length in meters of north-pointing component of vector
getRange () Length in meters of vector
getScaled (scale) Creates a scaled version of this vector.
getUnit () Creates a unit vector of this vector.
headingDiff (vector) Computes the heading difference between the two vectors.
makeCopy () Makes a copy of the given vector object.
makeVectorGeoc3DAtLoc (location) This function creates a VectorGeoc3D, i.e.
setBearingInclRange (bearing, inclination, range) Sets all three components of a vector.
setNorthEastDown (north, east, down) Sets all three components of a vector.


Functions

Vector3D (north, east, down)
Constructor for Vector3D.

Parameters:

  • north: North-pointing component, in meters.
  • east: East-pointing component, in meters.
  • down: Down-pointing component, in meters.

Return value:

    A Vector3D with the given components.
addOffset (offsetVector)
Creates a vector that is the sum of this vector and the given offset vector. The right, forward, and up components of the offset vector are considered to be relative to this vector3D; forward is in the same direction, right is always horizontal (down component is 0) and has a heading 90 degrees clockwise from forward, and up is perpendicular to forward and right.

Parameters:

  • offsetVector: An VectorOffset3D.

Return value:

    A Vector3D, the sum of this and the given offset vector.
addVector3D (vector)
Creates a vector that is the sum of this and the given vector.

Parameters:

  • vector: A Vector3D

Return value:

    A Vector3D that is the sum of the two vectors.
crossVector3D (vector)
Creates a vector that is the cross product of this vector with the given vector. I.e. this x vector.

Parameters:

  • vector: A Vector3D

Return value:

    A Vector3D
dotVector3D (vector)
Computes the dot product of this vector with the given one.

Parameters:

  • vector: A Vector3D

Return value:

    A number that is the dot product of this vector with the given vector.
getBearing ()
Angle in radians clockwise of the vector from north

Return value:

    Angle in radians representing the bearing of the vector, i.e. clockwise angle from north.
getDown ()
Length in meters of downward-pointing component of vector

Return value:

    The down-pointing component of the vector, in meters.
getEast ()
Length in meters of east-pointing component of vector

Return value:

    The east-pointing component of the vector, in meters.
getInclination ()
Angle in radians of vector from horizontal

Return value:

    Angle in radians representing the inclination of the vector, i.e. angle up from horizontal.
getNegated ()
Creates a vector that is the negation of this vector, i.e. (-north, -east, -down).

Return value:

    A Vector3D which is this vector negated.
getNorth ()
Length in meters of north-pointing component of vector

Return value:

    The north-pointing component of the vector, in meters.
getRange ()
Length in meters of vector

Return value:

    Length in meters of the vector (including vertical component).
getScaled (scale)
Creates a scaled version of this vector.

Parameters:

  • scale: A (scalar) number that this vector is multiplied by to produce the output vector.

Return value:

    A Vector3D which is this vector scaled by the input scale.
getUnit ()
Creates a unit vector of this vector. i.e. this / |this| .

Return value:

    A Vector3D which is a unit vector of this vector.
headingDiff (vector)
Computes the heading difference between the two vectors. I.e. the parameter vector heading - this heading, where heading is positive clockwise. The return value is between -Pi and Pi.

Parameters:

  • vector: A Vector3D

Return value:

    A number indicating the heading difference, in radians.
makeCopy ()
Makes a copy of the given vector object.

Return value:

    Vector3D that is a copy of this object.
makeVectorGeoc3DAtLoc (location)
This function creates a VectorGeoc3D, i.e. a geocentric vector, from a Vector3D fixed at a location on the earth.

Parameters:

  • location: A Location3D specifying the reference location.

Return value:

    A VectorGeoc3D
setBearingInclRange (bearing, inclination, range)
Sets all three components of a vector. Unlike setNorthEastDown, this function takes two angles and a range to define the vector.

Parameters:

  • bearing: The horizontal angle of the vector, in radians clockwise from north.
  • inclination: The vertical angle of the vector, in radians up from horizontal.
  • range: The length of the vector, in meters. Length includes the vertical component--it is not just distance in the horizontal plane.
setNorthEastDown (north, east, down)
Sets all three components of a vector. All parameters in meters.

Parameters:

  • north: The north component of the vector. Number of meters.
  • east: The east component of the vector. Number of meters.
  • down: The down component of the vector. Number of meters.

Copyright© 2024 MAK Technologies, Inc. All rights reserved.