Class DVec3d
public class DVec3d : IEquatable<DVec3d>, IWriteBin, IEqualityOperators<DVec3d, DVec3d, bool>, IAdditionOperators<DVec3d, DVec3d, DVec3d>, ISubtractionOperators<DVec3d, DVec3d, DVec3d>, IMultiplyOperators<DVec3d, double, DVec3d>, IMultiplyOperators<DVec3d, Mat4d, DVec3d>, IDivisionOperators<DVec3d, double, DVec3d>, IVec<double>, IFormattable
- Inheritance
-
DVec3d
- Implements
- Inherited Members
- Extension Methods
Constructors
DVec3d()
Ctor. The members are initialized to null.
public DVec3d()
DVec3d(DVec3d, bool)
Initializes a new instance of the DVec3d class by copying another DVec3d.
public DVec3d(DVec3d src, bool shareFields = false)
Parameters
src
DVec3dThe source DVec3d to copy from.
shareFields
boolIf true, references to the source Point and Normal are used; otherwise, new instances are created with copied values.
DVec3d(Mat4d)
Ctor.
set mat
[12] to Point.x;
set mat
[13] to Point.y;
set mat
[14] to Point.z;
set mat
[8] to Normal.x;
set mat
[9] to Normal.y;
set mat
[10] to Normal.z;
public DVec3d(Mat4d mat)
Parameters
mat
Mat4dmatrix
DVec3d(UnnullableDVec3d)
Initializes a new instance of the DVec3d class from an UnnullableDVec3d.
public DVec3d(UnnullableDVec3d src)
Parameters
src
UnnullableDVec3dThe source UnnullableDVec3d to copy from.
DVec3d(Vec3d, Vec3d)
Ctor.
public DVec3d(Vec3d p, Vec3d n)
Parameters
DVec3d(IEnumerable<double>)
Initializes a new instance of the DVec3d class from an enumerable collection of doubles.
public DVec3d(IEnumerable<double> src)
Parameters
src
IEnumerable<double>The source collection containing at least 6 double values. The first 3 values initialize the Point, and the last 3 values initialize the Normal.
DVec3d(double, double, double, double, double, double)
Ctor.
public DVec3d(double px, double py, double pz, double nx, double ny, double nz)
Parameters
DVec3d(double[])
Ctor.
public DVec3d(double[] src)
Parameters
src
double[]Array elements 0,1,2 initialize Point x,y,z; Array elements 3,4,5 initialize Point x,y,z
DVec3d(Func<int, double>)
Initializes a new instance of the DVec3d class using a function that maps indices to values.
public DVec3d(Func<int, double> dirToValueFunc)
Parameters
dirToValueFunc
Func<int, double>A function that takes an index (0-5) and returns the corresponding coordinate value. Indices 0-2 are for Point coordinates, and 3-5 are for Normal coordinates.
DVec3d(BinaryReader)
Initializes a new instance of the DVec3d class from binary data.
public DVec3d(BinaryReader reader)
Parameters
reader
BinaryReaderThe binary reader to read the data from.
DVec3d(string)
Ctor. The reading format is ((x,y,z),(x,y,z)), the first xyz is for Point; the second xyz is for Normal.
public DVec3d(string str)
Parameters
str
stringstring
- See Also
Properties
ElementNum
Element number: 6 for (Point(x,y,z),Normal(x,y,z)).
public static int ElementNum { get; }
Property Value
IsAllNaN
Gets a value indicating whether all components of both Point and Normal are NaN.
public bool IsAllNaN { get; }
Property Value
IsFinite
Gets a value indicating whether all components of both Point and Normal are finite.
public bool IsFinite { get; }
Property Value
this[int]
Gets or sets the element at the specified index.
public double this[int index] { get; set; }
Parameters
index
intThe zero-based index of the element to get or set.
Property Value
- double
The element at the specified index.
NaN
Gets a DVec3d with all components set to NaN.
public static DVec3d NaN { get; }
Property Value
Normal
Normal.
public Vec3d Normal { get; set; }
Property Value
Point
Point.
public Vec3d Point { get; set; }
Property Value
Rank
Dimension (i.e. Size) of the Vector.
public int Rank { get; }
Property Value
Zero
Gets a DVec3d with all components set to zero.
public static DVec3d Zero { get; }
Property Value
Methods
At(int)
Gets a reference to the component at the specified index.
public ref double At(int dir)
Parameters
dir
intThe index of the component to access (0-5). Indices 0-2 access Point coordinates (x,y,z), and indices 3-5 access Normal coordinates (x,y,z).
Returns
- double
A reference to the specified component.
Enumerate()
public IEnumerable<double> Enumerate()
Returns
Equals(DVec3d)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(DVec3d other)
Parameters
other
DVec3dAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GenNaN()
Creates a new DVec3d with all components set to NaN.
public static DVec3d GenNaN()
Returns
- DVec3d
A new DVec3d with all components set to NaN.
GenZero()
Creates a new DVec3d with all components set to zero.
public static DVec3d GenZero()
Returns
- DVec3d
A new DVec3d with all components set to zero.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Interpolate(DVec3d, DVec3d, double)
Interpolates between two DVec3d instances.
public static DVec3d Interpolate(DVec3d a, DVec3d b, double ratio)
Parameters
a
DVec3dThe first DVec3d.
b
DVec3dThe second DVec3d.
ratio
doubleThe interpolation ratio (0.0 to 1.0).
Returns
- DVec3d
A new DVec3d interpolated between a and b.
Set(DVec3d, bool)
Sets the values of this instance from another DVec3d.
public void Set(DVec3d src, bool shareFields = false)
Parameters
src
DVec3dThe source DVec3d to copy values from.
shareFields
boolIf true, references to the source Point and Normal are used; otherwise, their values are copied.
Set(double, double, double, double, double, double)
Call Point.Set(double, double, double) and Normal.Set(double, double, double) to set the values.
public void Set(double px, double py, double pz, double nx, double ny, double nz)
Parameters
Remarks
SetEachValueAbs()
Sets each component of both Point and Normal to its absolute value.
public DVec3d SetEachValueAbs()
Returns
- DVec3d
This instance after the operation.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToString(string)
Returns a string representation of this DVec3d using the specified format for component values.
public string ToString(string format)
Parameters
format
stringThe format string to use for component values.
Returns
- string
A string representation of this DVec3d.
ToString(string, IFormatProvider)
Returns a string representation of the dual vector formatted according to the specified format.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format to use for each component
formatProvider
IFormatProviderThe format provider to use
Returns
- string
A formatted string representation of the dual vector
ToUnnullableDVec3d()
Converts this DVec3d to an UnnullableDVec3d.
public UnnullableDVec3d ToUnnullableDVec3d()
Returns
- UnnullableDVec3d
A new UnnullableDVec3d containing the data from this DVec3d.
WriteBin(BinaryWriter)
Writes the object's data to a binary stream.
public void WriteBin(BinaryWriter writer)
Parameters
writer
BinaryWriterThe binary writer to write to
Operators
operator +(DVec3d, DVec3d)
Adds two values together to compute their sum.
public static DVec3d operator +(DVec3d a, DVec3d b)
Parameters
Returns
- DVec3d
The sum of
left
andright
.
operator /(DVec3d, double)
Divides one value by another to compute their quotient.
public static DVec3d operator /(DVec3d src, double s)
Parameters
Returns
- DVec3d
The quotient of
left
divided byright
.
operator ==(DVec3d, DVec3d)
Compares two values to determine equality.
public static bool operator ==(DVec3d left, DVec3d right)
Parameters
Returns
operator !=(DVec3d, DVec3d)
Compares two values to determine inequality.
public static bool operator !=(DVec3d left, DVec3d right)
Parameters
Returns
operator *(DVec3d, Mat4d)
Multiplies two values together to compute their product.
public static DVec3d operator *(DVec3d a, Mat4d b)
Parameters
Returns
- DVec3d
The product of
left
multiplied byright
.
operator *(DVec3d, double)
Multiplies two values together to compute their product.
public static DVec3d operator *(DVec3d src, double s)
Parameters
Returns
- DVec3d
The product of
left
multiplied byright
.
operator -(DVec3d, DVec3d)
Subtracts two values to compute their difference.
public static DVec3d operator -(DVec3d a, DVec3d b)
Parameters
Returns
- DVec3d
The value of
right
subtracted fromleft
.
operator -(DVec3d)
Create a negate DVec3d.
The field objects are created, i.e. the field objects are not shared with this
.
public static DVec3d operator -(DVec3d src)
Parameters
src
DVec3dsrc