Struct Vector
Structure defining a vector in three-dimensional euclidean space.
Implements
Namespace: BRIDGES.Geometry.Euclidean3D
Assembly: BRIDGES.dll
Syntax
public struct Vector : IDotProduct<Vector, double>, INorm<Vector>, IMetric<Vector>, IGroupAction<Vector, double>
Constructors
| Improve this Doc View SourceVector(Point, Point)
Declaration
public Vector(Point start, Point end)
Parameters
Type | Name | Description |
---|---|---|
Point | start | Point at start. |
Point | end | Point at end. |
Vector(Vector)
Declaration
public Vector(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | Vector to deep copy. |
Vector(Double, Double, Double)
Initialises a new instance of the Vector structure by defining its three coordinates.
Declaration
public Vector(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
Double | x | Value of the first coordinate. |
Double | y | Value of the second coordinate. |
Double | z | Value of the third coordinate. |
Vector(Double[])
Initialises a new instance of Vector structure by defining its coordinates.
Declaration
public Vector(double[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
Double[] | coordinates | Value of the coordinates. |
Properties
| Improve this Doc View SourceDimension
Gets the dimension of this Vector's euclidean space.
Declaration
public readonly int Dimension { get; }
Property Value
Type | Description |
---|---|
Int32 |
Item[Int32]
Gets or sets the value of the coordinate at the given index.
Declaration
public double this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the coordinate to get or set. |
Property Value
Type | Description |
---|---|
Double | The value of the coordinate at the given index. |
WorldX
Gets a new Vector with coordinates (1.0, 0.0, 0.0)
.
Declaration
public static readonly Vector WorldX { get; }
Property Value
Type | Description |
---|---|
Vector |
WorldY
Gets a new Vector with coordinates (0.0, 1.0, 0.0)
.
Declaration
public static readonly Vector WorldY { get; }
Property Value
Type | Description |
---|---|
Vector |
WorldZ
Gets a new Vector with coordinates (0.0, 0.0, 1.0)
.
Declaration
public static readonly Vector WorldZ { get; }
Property Value
Type | Description |
---|---|
Vector |
X
Gets or sets the first coordinate of this Vector.
Declaration
public double X { get; set; }
Property Value
Type | Description |
---|---|
Double |
Y
Gets or sets the second coordinate of this Vector.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
Double |
Z
Gets or sets the third coordinate of this Vector.
Declaration
public double Z { get; set; }
Property Value
Type | Description |
---|---|
Double |
Zero
Gets a new Vector with coordinates (0.0, 0.0, 0.0)
.
Declaration
public static readonly Vector Zero { get; }
Property Value
Type | Description |
---|---|
Vector |
Methods
| Improve this Doc View SourceAdd(Point, Vector)
Declaration
public static Vector Add(Point left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Point | left | Point for the addition. |
Vector | right | Vector for the addition. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the addition. |
Add(Vector, Point)
Declaration
public static Vector Add(Vector left, Point right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the addition. |
Point | right | Point for the addition. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the addition. |
Add(Vector, Vector)
Computes the addition of two Vector.
Declaration
public static Vector Add(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the addition. |
Vector | right | Vector for the addition. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the addition. |
AngleBetween(Vector, Vector)
Computes the angle between two Vector.
Declaration
public static double AngleBetween(Vector vectorA, Vector vectorB)
Parameters
Type | Name | Description |
---|---|---|
Vector | vectorA | Vector for the angle evaluation. |
Vector | vectorB | Vector for the angle evaluation. |
Returns
Type | Description |
---|---|
Double | The value of the angle between the two Vector (in radians). |
AngleWith(Vector)
Declaration
public double AngleWith(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other | Vector to compare with. |
Returns
Type | Description |
---|---|
Double | The value of the angle (in radians). |
AreOrthogonal(Vector, Vector)
Evaluates whether two Vector are orthogonal.
Declaration
public static bool AreOrthogonal(Vector vectorA, Vector vectorB)
Parameters
Type | Name | Description |
---|---|---|
Vector | vectorA | Vector for the comparison. |
Vector | vectorB | Vector for the comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the two Vector are orthogonal, false otherwise. |
AreOrthogonal(Vector[])
Evaluates whether a collection of Vector are orthogonal to one another.
Declaration
public static bool AreOrthogonal(params Vector[] vectors)
Parameters
Type | Name | Description |
---|---|---|
Vector[] | vectors | Collection of Vector to evaluate. |
Returns
Type | Description |
---|---|
Boolean | true if the Vector are orthogonal, false otherwise. |
AreParallel(Vector, Vector)
Evaluates whether two Vector are parallel.
Declaration
public static bool AreParallel(Vector vectorA, Vector vectorB)
Parameters
Type | Name | Description |
---|---|---|
Vector | vectorA | Vector for the comparison. |
Vector | vectorB | Vector for the comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the two Vector are parallel, false otherwise. |
CrossProduct(Vector, Vector)
Returns the cross product of two Vector.
Declaration
public static Vector CrossProduct(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Left Vector for the cross product. |
Vector | right | Right Vector for the cross product. |
Returns
Type | Description |
---|---|
Vector | A new Vector resulting from the cross product of two Vector. |
Divide(Vector, Double)
Computes the scalar division of a Vector with a
Declaration
public static Vector Divide(Vector operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
Vector | operand | Vector to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar division. |
DotProduct(Vector, Vector)
Computes the dot product of two Vector.
Declaration
public static double DotProduct(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the dot product. |
Vector | right | Vector for the dot product. |
Returns
Type | Description |
---|---|
Double | The new Vector resulting from the dot product of two Vector. |
Equals(Vector)
Declaration
public bool Equals(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other | Vector to compare with. |
Returns
Type | Description |
---|---|
Boolean | true if the two Vector are equal, false otherwise. |
Remarks
Two Vector are equal if their coordinates are equal.
Equals(Object)
Structure defining a vector in three-dimensional euclidean space.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
GetCoordinates()
Gets the coordinates of this Vector.
Declaration
public double[] GetCoordinates()
Returns
Type | Description |
---|---|
Double[] | The array representation of the Vector's coordinates. |
GetHashCode()
Structure defining a vector in three-dimensional euclidean space.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
IsUnit()
Evaluates whether this Vector's length is one.
Declaration
public bool IsUnit()
Returns
Type | Description |
---|---|
Boolean | true if this Vector is of unit length, false otherwise. |
Length()
Computes the length of this Vector (using the L2-norm).
Declaration
public double Length()
Returns
Type | Description |
---|---|
Double | The value of this Vector's length. |
Multiply(Vector, Double)
Computes the right scalar multiplication of a Vector with a
Declaration
public static Vector Multiply(Vector operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
Vector | operand | Vector to multiply. |
Double | factor |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar multiplication. |
Multiply(Double, Vector)
Computes the left scalar multiplication of a Vector with a
Declaration
public static Vector Multiply(double factor, Vector operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
Vector | operand | Vector to multiply. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar multiplication. |
SquaredLength()
Computes the squared length of this Vector (using the L2-norm).
Declaration
public double SquaredLength()
Returns
Type | Description |
---|---|
Double | The value of this Vector's squared length. |
Subtract(Point, Vector)
Declaration
public static Vector Subtract(Point left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Point | left | Point to subtract. |
Vector | right | Vector to subtract with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the subtraction. |
Subtract(Vector, Point)
Declaration
public static Vector Subtract(Vector left, Point right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector to subtract. |
Point | right | Point to subtract with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the subtraction. |
Subtract(Vector, Vector)
Computes the subtraction of two Vector.
Declaration
public static Vector Subtract(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector to subtract. |
Vector | right | Vector to subtract with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the subtraction. |
ToString()
Structure defining a vector in three-dimensional euclidean space.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Unitise()
Unitises this Vector (using the L2-norm).
Declaration
public void Unitise()
Operators
| Improve this Doc View SourceAddition(Vector, Point)
Declaration
public static Vector operator +(Vector left, Point right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the addition. |
Point | right | Point for the addition. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the addition. |
Addition(Vector, Vector)
Computes the addition of two Vector.
Declaration
public static Vector operator +(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the addition. |
Vector | right | Vector for the addition. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the addition. |
Division(Vector, Double)
Computes the scalar division of a Vector with a
Declaration
public static Vector operator /(Vector operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
Vector | operand | Vector to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar division. |
Implicit(Point to Vector)
Declaration
public static implicit operator Vector(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to convert. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the conversion. |
Multiply(Vector, Vector)
Computes the dot product of two Vector.
Declaration
public static double operator *(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector for the dot product. |
Vector | right | Vector for the dot product. |
Returns
Type | Description |
---|---|
Double | The new Vector resulting from the dot product of two Vector. |
Multiply(Vector, Double)
Computes the right scalar multiplication of a Vector with a
Declaration
public static Vector operator *(Vector operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
Vector | operand | Vector to multiply. |
Double | factor |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar multiplication. |
Multiply(Double, Vector)
Computes the left scalar multiplication of a Vector with a
Declaration
public static Vector operator *(double factor, Vector operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
Vector | operand | Vector to multiply. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the scalar multiplication. |
Subtraction(Vector, Point)
Declaration
public static Vector operator -(Vector left, Point right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector to subtract. |
Point | right | Point to subtract with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the subtraction. |
Subtraction(Vector, Vector)
Computes the subtraction of two Vector.
Declaration
public static Vector operator -(Vector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
Vector | left | Vector to subtract. |
Vector | right | Vector to subtract with. |
Returns
Type | Description |
---|---|
Vector | The new Vector resulting from the subtraction. |
UnaryNegation(Vector)
Computes the opposite of the given Vector.
Declaration
public static Vector operator -(Vector operand)
Parameters
Type | Name | Description |
---|---|---|
Vector | operand | Vector to be opposed. |
Returns
Type | Description |
---|---|
Vector | The new Vector, opposite of the initial one. |
Explicit Interface Implementations
| Improve this Doc View SourceIDotProduct<Vector, Double>.DotProduct(Vector)
Computes the dot product of this element with another element.
Declaration
double IDotProduct<Vector, double>.DotProduct(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other |
Returns
Type | Description |
---|---|
Double | The value of the dot product of the two elements. |
IMetric<Vector>.DistanceTo(Vector)
Computes the distance of this element to another element.
Declaration
double IMetric<Vector>.DistanceTo(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other |
Returns
Type | Description |
---|---|
Double | The value of the distance between the two elements. |
INorm<Vector>.Norm()
Computes the norm of this element.
Declaration
double INorm<Vector>.Norm()
Returns
Type | Description |
---|---|
Double | The value of the norm. |
IGroupAction<Vector, Double>.Divide(Double)
Computes the right scalar division of the current element.
Declaration
Vector IGroupAction<Vector, double>.Divide(double divisor)
Parameters
Type | Name | Description |
---|---|---|
Double | divisor |
Returns
Type | Description |
---|---|
Vector | The new element resulting from the scalar dividion. |
IGroupAction<Vector, Double>.Multiply(Double)
Computes the right scalar multiplication of the current element.
Declaration
Vector IGroupAction<Vector, double>.Multiply(double factor)
Parameters
Type | Name | Description |
---|---|---|
Double | factor |
Returns
Type | Description |
---|---|
Vector | The new element resulting from the scalar multiplication. |