Provides access to vector properties and operations.
Description
A general vector interface containing functions to manipulate vectors in an arbitrary number of dimensions. Contains basic vector characteristics including Dimension and Magnitude as well as general vector operations including Normalization, scalar nultiplication, Vector Addition, Vector Subtraction, Vector Dot Product, and Vector Cross Product. To access methods specific to 3D Vectors, use the IVector3D interface.
Members
Name | Description | |
---|---|---|
AddVector | Construct a new vector by adding a different vector to this vector. | |
ComponentByIndex | The component corresponding to a given index. | |
ConstructAddVector | Set this vector by adding two input vectors. | |
ConstructSubtractVector | Set this vector by subtracting the second input vector from the first one. | |
Dimension | The dimension of this vector. | |
DotProduct | Returns the dot product of this vector and another vector. | |
IsEmpty | Indicates if the vector is empty (unset). | |
Magnitude | The length of the vector. | |
Normalize | Normalize the vector (scale it to magnitude = 1). | |
Scale | Scale the vector by the given factor. | |
SetEmpty | Makes the vector empty (unset). | |
SubtractVector | Construct a new vector by subtracting a different vector from this vector. |
IVector.AddVector Method
Construct a new vector by adding a different vector to this vector.
Public Function AddVector ( _
ByVal otherVector As IVector _
) As IVector
public IVector AddVector (
IVector otherVector
);
Description
Returns a newly constructed Vector by adding the components of the base vector to the corresponding components of the input vector.
Remarks
IVector.ComponentByIndex Property
The component corresponding to a given index.
Public Function get_ComponentByIndex ( _
ByVal componentIndex As Integer _
) As Double
Public Sub set_ComponentByIndex ( _
ByVal componentIndex As Integer, _
ByVal componentValue As Double _
)
public double get_ComponentByIndex (
int componentIndex
);
public void set_ComponentByIndex (
int componentIndex,
double componentValue
);
Description
Returns or sets the value of the component of the specified index. The first component has index 0. An Nth Dimensional vector has N components (0, 1, . . ., N-2, N-1).
IVector.ConstructAddVector Method
Set this vector by adding two input vectors.
Public Sub ConstructAddVector ( _
ByVal vector1 As IVector, _
ByVal vector2 As IVector _
)
public void ConstructAddVector (
IVector vector1,
IVector vector2
);
Description
Constructs a new Vector by adding the components of the first vector to the corresponding components of the second vector.
Remarks
IVector.ConstructSubtractVector Method
Set this vector by subtracting the second input vector from the first one.
Public Sub ConstructSubtractVector ( _
ByVal vector1 As IVector, _
ByVal vector2 As IVector _
)
public void ConstructSubtractVector (
IVector vector1,
IVector vector2
);
Description
Constructs a new Vector by subtracting the components of the second vector from the corresponding components of the first vector.
Remarks
IVector.Dimension Property
The dimension of this vector.
Public ReadOnly Property Dimension As Integer
public int Dimension {get;}
Description
Returns the Dimension of the Vector. The Dimension corresponds to the number of unique Components that define the vector.
Remarks
IVector.DotProduct Method
Returns the dot product of this vector and another vector.
Public Function DotProduct ( _
ByVal otherVector As IVector _
) As Double
public double DotProduct (
IVector otherVector
);
Description
Returns a double representing the Dot Product of the base vector and the input vector. The Dot Product is the sum of multiplying corresponding components of each vector.
IVector.IsEmpty Property
Indicates if the vector is empty (unset).
Public ReadOnly Property IsEmpty As Boolean
public bool IsEmpty {get;}
Description
Returns TRUE if all of the components of the vector have undefined (NaN) values. An Empty vector is NOT the same as a Null vector.
IVector.Magnitude Property
The length of the vector.
Public Property Magnitude As Double
public double Magnitude {get; set;}
Description
Returns and sets the magnitude of the vector. The magnitude is analgous to the length of the vector.
Remarks
IVector.Normalize Method
Normalize the vector (scale it to magnitude = 1).
Public Sub Normalize ( _
)
public void Normalize (
);
Description
Normalizes the Vector to a unit vector with Magnitude = 1 and the same direction as the original vector.
Remarks
Normalize is the same as Scaling the vector by 1 / Magnitude.
IVector.Scale Method
Scale the vector by the given factor.
Public Sub Scale ( _
ByVal ScaleFactor As Double _
)
public void Scale (
double ScaleFactor
);
Description
Multiplies each component of the Vector by a given Scale factor. If the scale factor is positive, the resulting scaled vector has the same direction as the original vector. If the scale factor is negative, the resulting scaled vector has the opposite direction as the original vector. The Magnitude of the scaled vector = OriginalMagnitude * Abs(ScaleFactor).
Remarks
Scaling a Vector by 1 / Magnitude effectively Normalizes the vector and results in a unit vector.
IVector.SetEmpty Method
Makes the vector empty (unset).
Public Sub SetEmpty ( _
)
public void SetEmpty (
);
Description
Sets the vector equal to an empty vector in which all components have undefined (NaN) values.
IVector.SubtractVector Method
Construct a new vector by subtracting a different vector from this vector.
Public Function SubtractVector ( _
ByVal otherVector As IVector _
) As IVector
public IVector SubtractVector (
IVector otherVector
);
Description
Returns a newly constructed Vector by subtracting the components of the input vector from the corresponding components of the base vector.
Remarks
Classes that implement IVector
Classes | Description |
---|---|
Vector3D | A 3D vector containing dx, dy, and dz components. |