- Contents
- Initializer
-
Methods
- dimension
- dimensionHR
- magnitude
- unitVector
- axisUnitVector
- x
- y
- z
- direction
- Addition operator (+)
- Subtraction operator (-)
- Subtraction operator (-)
- Multiplication operator (*)
- Division operator (/)
- Multiplication operator (*)
- Equality operator (==)
- dot
- cross
- angleBetween
- orthogonalTo
- parallelTo
- getValue
- copy
- Class functions
- Type interfaces
Math::Vector
This is the Math::Vector class.
Represents a vector of any dimension.
Initializer
$v = Vector()
Creates a vector with the given components.
- optional items: Num... Variable number of arguments.
Methods
dimension
$v.dimension
Computed property. Dimension of the vector.
dimensionHR
$v.dimensionHR
Computed property. Human-readable dimension of the vector.
magnitude
$v.magnitude
Computed property. Magnitude of the vector.
unitVector
$v.unitVector
Computed property. Unit vector in the direction of this vector.
axisUnitVector
$v.axisUnitVector($axis: VectorAxis)
Returns the unit vector in the direction of the given axis.
- axis: VectorAxis - Axis number or letter, starting at 1 or "i".
x
$v.x
Computed property. For a >=1D vector, the first comonent.
y
$v.y
Computed property. For a >=2D vector, the second component.
z
$v.z
Computed property. For a >=3D vector, the third component.
direction
$v.direction
Computed property. For a 2D vector, its direction, measured in radians.
Addition operator (+)
$v + ($ehs: Vector)
Addition of two vectors.
Subtraction operator (-)
$v - ($lhs: Num)
Allows you to take the opposite vector -$u
.
Subtraction operator (-)
$v - ($rhs: Vector)
Subtraction of a vector from another.
Multiplication operator (*)
$v * ($ehs: Num)
Scalar multiplication of the vector.
Division operator (/)
$v / ($rhs: Num)
Scalar division of the vector.
Multiplication operator (*)
$v * ($ehs: Vector)
Dot product of two vectors.
Equality operator (==)
$v == ($ehs: Vector)
Vector equality.
dot
$v.dot($ehs: Vector)
Dot product of this vector and another of the same dimension.
-
ehs: Vector
cross
$v.cross($ehs: Vector)
Cross product of two 3D vectors.
-
ehs: Vector
angleBetween
$v.angleBetween($ehs: Vector)
Angle between this vector and another of the same dimension, measured in radians.
-
ehs: Vector
orthogonalTo
$v.orthogonalTo($ehs: Vector)
True if this vector is orthogonal to another of the same dimension.
-
ehs: Vector
parallelTo
$v.parallelTo($ehs: Vector)
True if this vector is parallel to another of the same dimension.
-
ehs: Vector
getValue
$v.getValue($index: Num)
Fetches the component at the given index. Allows Vector to conform to
IndexedRead such that $vector[N]
is the N+1th component.
-
index: Num
copy
$v.copy()
Returns a copy of the vector.
Class functions
zeroVector
Vector.zeroVector($dimension: Num)
Returns the zero vector in the given dimension.
-
dimension: Num
axisUnitVector
Vector.axisUnitVector($dimension: Num, $axis: VectorAxis)
Returns the unit vector for the given dimension and axis.
-
dimension: Num
-
axis: VectorAxis - Axis number or letter, starting at 1 or "i".
Type interfaces
VectorAxis
An interface which accepts an axis letter starting at "i" or number starting at 1. For instance, a 3D vector is represented by axes i, j, and k, which correspond to the numbers 1, 2, and 3, respectively.
In order to comply, the object must satisfy the following condition.
- transform: Converts letters starting at 'i' to axis numbers.
End of the Math::Vector class.
This file was generated automatically by the Ferret compiler from Vector.frt.