Class Vector
The Vector Class: Defines vector mathematics and functionality for the dxf library
Implements
Inherited Members
Namespace: Dxflib.LinAlg
Assembly: Dxflib.dll
Syntax
public class Vector : GeoBase, INotifyPropertyChanged
Constructors
| Improve this Doc View SourceVector()
Default Constructor
Declaration
public Vector()
Vector(GeoLine)
Constructor from a line
Declaration
public Vector(GeoLine line)
Parameters
Type | Name | Description |
---|---|---|
GeoLine | line |
Vector(Vertex, Vertex)
PositionVector Constructor: This will create a vector with its tail at the origin and it's head at where the components are on the cartesian 3D space.
Declaration
public Vector(Vertex startingVertex, Vertex endingVertex)
Parameters
Type | Name | Description |
---|---|---|
Vertex | startingVertex | The Starting Vertex for the position vector |
Vertex | endingVertex | The Ending Vertex for the position vector |
Vector(Vector)
Constructor from another vector
Declaration
public Vector(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other |
Vector(Double, Double, Double)
UnitVector Constructor
Declaration
public Vector(double xComponent, double yComponent, double zComponent = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double | xComponent | The x component of a unit vector |
System.Double | yComponent | The y component of a unit vector |
System.Double | zComponent | The z component of a unit vector |
Properties
| Improve this Doc View SourceHeadVertex
The Head of the vector or the ending vector (Point of Application)
Declaration
public Vertex HeadVertex { get; set; }
Property Value
Type | Description |
---|---|
Vertex |
Length
The vector's length or magnitude
Declaration
public double Length { get; }
Property Value
Type | Description |
---|---|
System.Double |
Slope
The 2D Slope of the vector (dY/dX)
Declaration
public double Slope { get; }
Property Value
Type | Description |
---|---|
System.Double |
TailVertex
The Tail of the vector: where the vector originates
Declaration
public Vertex TailVertex { get; set; }
Property Value
Type | Description |
---|---|
Vertex |
X
The vector's x component
Declaration
public double X { get; }
Property Value
Type | Description |
---|---|
System.Double |
Y
The vector's y component
Declaration
public double Y { get; }
Property Value
Type | Description |
---|---|
System.Double |
Z
The vector's z component
Declaration
public double Z { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceAngleBetweenVectors(Vector, Vector)
The Angle between two vectors
Declaration
public static double AngleBetweenVectors(Vector vec0, Vector vec1)
Parameters
Type | Name | Description |
---|---|---|
Vector | vec0 | Vector 1 |
Vector | vec1 | Vector 2 |
Returns
Type | Description |
---|---|
System.Double | The angle between two vectors in radians |
CrossProduct(Vector)
The Cross product of this vector and the other vector (ThisVector x OtherVector)
Declaration
public Vector CrossProduct(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other | The other vector that is in the cross function |
Returns
Type | Description |
---|---|
Vector | A new vector that is the resultant of the cross product |
DotProduct(Vector)
The Mathematical Dot Product of two vectors
Declaration
public double DotProduct(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other | The other vector in the dot product equation |
Returns
Type | Description |
---|---|
System.Double | A double value that is the dot product of other and this vector |
Rotate(Double)
Rotate the vector about is tail
Declaration
public void Rotate(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | Rotation angle in radians |
Scale(Double)
Declaration
public void Scale(double scaler)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scaler |
ToUnitVector()
Creates a new vector that is the unit vector of this vector
Declaration
public Vector ToUnitVector()
Returns
Type | Description |
---|---|
Vector | A new Vector object |
Transform(Vector, Vector, Vector)
Transform method transforms this vector using a new set of basis vectors
Declaration
public void Transform(Vector newXBasis, Vector newYBasis, Vector newZBasis)
Parameters
Type | Name | Description |
---|---|---|
Vector | newXBasis | The new basis for the x component |
Vector | newYBasis | The new basis for the y component |
Vector | newZBasis | The new basis for the z component |
Translate(Vertex)
Translate a vertex to a new point by its tail
Declaration
public void Translate(Vertex newTail)
Parameters
Type | Name | Description |
---|---|---|
Vertex | newTail | The new tail vertex |
UpdateGeometry(String)
Update the Geometry of the Vector
Declaration
protected override sealed void UpdateGeometry(string command = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | command |
Overrides
Operators
| Improve this Doc View SourceAddition(Vector, Vector)
The Addition overload operator for the vector class
Declaration
public static Vector operator +(Vector vec1, Vector vec2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vec1 | |
Vector | vec2 |
Returns
Type | Description |
---|---|
Vector |
Division(Vector, Double)
Declaration
public static Vector operator /(Vector vec, double scaler)
Parameters
Type | Name | Description |
---|---|---|
Vector | vec | |
System.Double | scaler |
Returns
Type | Description |
---|---|
Vector |
Multiply(Vector, Double)
The overloaded operator *
Declaration
public static Vector operator *(Vector vec, double scaler)
Parameters
Type | Name | Description |
---|---|---|
Vector | vec | |
System.Double | scaler |
Returns
Type | Description |
---|---|
Vector | A new vector that is the resultant of the scaler |
Multiply(Double, Vector)
Declaration
public static Vector operator *(double scaler, Vector vec)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scaler | |
Vector | vec |
Returns
Type | Description |
---|---|
Vector |
Subtraction(Vector, Vector)
The overloaded operator "-"
Declaration
public static Vector operator -(Vector vec1, Vector vec2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vec1 | |
Vector | vec2 |
Returns
Type | Description |
---|---|
Vector | A new vector that is the resultant of the subtraction |