VR-Forces 5.2 Lua Function Documentation

VectorOffset3D

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

A VectorOffset3D is a direction vector that is relative to some direction specified by a Vector3D. E.g. this may be a "body" vector that is situated on an entity oriented in the world. A VectorOffset3D can be used to generate a direction in the world by transforming it to the direction of a Vector3D or adding it to a Vector3D.

Function List

VectorOffset3D (right, forward, up) The constructor for a VectorOffset3D.
addOffset (offsetVector) Creates an offset vector that is the sum of this vector and the given vector.
crossVectorOffset3D (offsetVector) Creates an offset vector that is the cross product of this vector with the given vector, i.e.
dotVectorOffset3D (offsetVector) Computes the dot product of this vector with the given one.
getForward () Length in meters of forward-pointing component of offset vector
getNegated () Creates a vector that is the negation of this vector.
getRight () Length in meters of right-pointing component of offset vector
getScaled (scale) Creates a scaled version of this vector.
getUnit () Creates a unit vector of this vector.
getUp () Length in meters of up-pointing component of offset vector
makeCopy () Makes a copy of the given vector object.
makeVectorRefToDirection (dirVect) Make this offset into an earth-referenced vector by transforming it to be relative to the orientation of the provided vector.
setForward (forward) Set Length in meters of forward-pointing component of offset vector
setRight (right) Set length in meters of right-pointing component of offset vector
setUp (up) Set length in meters of up-pointing component of offset vector


Functions

VectorOffset3D (right, forward, up)
The constructor for a VectorOffset3D. All parameters in meters.

Parameters:

  • right: The component of the vector to the right. Number of meters.
  • forward: The component of the vector in the forward direction. Number of meters.
  • up: The component of the vector upward. Number of meters.

Return value:

    A VectorOffset3D.
addOffset (offsetVector)
Creates an offset vector that is the sum of this vector and the given vector.

Parameters:

  • offsetVector: A VectorOffset3D

Return value:

    A VectorOffset3D, the sum of this and the parameter vector.
crossVectorOffset3D (offsetVector)
Creates an offset vector that is the cross product of this vector with the given vector, i.e. this x offsetVector.

Parameters:

  • offsetVector: A VectorOffset3D

Return value:

    A VectorOffset3D
dotVectorOffset3D (offsetVector)
Computes the dot product of this vector with the given one.

Parameters:

  • offsetVector: A VectorOffset3D

Return value:

    A number that is the dot product of this vector with the given vector.
getForward ()
Length in meters of forward-pointing component of offset vector

Return value:

    The Forward component of the offset vector.
getNegated ()
Creates a vector that is the negation of this vector. I.e. (-right, -forward, -up).

Return value:

    A VectorOffset3D which is this vector negated.
getRight ()
Length in meters of right-pointing component of offset vector

Return value:

    The Right component of the offset vector.
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 VectorOffset3D which is this vector scaled by the input scale.
getUnit ()
Creates a unit vector of this vector. I.e. this / |this| .

Return value:

    A VectorOffset3D which is a unit vector of this vector.
getUp ()
Length in meters of up-pointing component of offset vector

Return value:

    The Up component of the offset vector.
makeCopy ()
Makes a copy of the given vector object.

Return value:

    VectorOffset3D that is a copy of this object.
makeVectorRefToDirection (dirVect)
Make this offset into an earth-referenced vector by transforming it to be relative to the orientation of the provided vector. "Orientation" assumes no roll.
Example: This offset vector is (1, 1, 0) (points right and forward, i.e. an angle of 45 degrees right from forward). The reference vector (0, 1, 0) (points east). The resulting vector would be (-1, 1, 0) (points south and east).

Parameters:

  • dirVect: A Vector3D indicating the reference direction

Return value:

    A Vector3D that is this offset vector transformed to the given direction.
setForward (forward)
Set Length in meters of forward-pointing component of offset vector

Parameters:

  • forward: The Forward component of the offset vector, in meters.
setRight (right)
Set length in meters of right-pointing component of offset vector

Parameters:

  • right: The Right component of the offset vector, in meters.
setUp (up)
Set length in meters of up-pointing component of offset vector

Parameters:

  • up: The Up component of the offset vector, in meters.

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