/// <summary> /// vector-and-scalar constructor (CAUTION: not angle-axis, use FromAngleAxis instead) /// </summary> public cquat(cvec3 v, Complex s) { this.x = v.x; this.y = v.y; this.z = v.z; this.w = s; }
/// <summary> /// Returns a vector rotated by the quaternion. /// </summary> public static cvec3 operator*(cquat q, cvec3 v) { var qv = new cvec3(q.x, q.y, q.z); var uv = cvec3.Cross(qv, v); var uuv = cvec3.Cross(qv, uv); return(v + ((uv * q.w) + uuv) * 2); }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat2x3(cvec3 c0, cvec3 c1) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat2x4(cvec3 c0, cvec3 c1) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m03 = Complex.Zero; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m13 = Complex.Zero; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat3(cvec3 c0, cvec3 c1, cvec3 c2) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m20 = c2.x; this.m21 = c2.y; this.m22 = c2.z; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat3(cvec3 c0, cvec3 c1) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m20 = Complex.Zero; this.m21 = Complex.Zero; this.m22 = Complex.One; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat4x3(cvec3 c0, cvec3 c1, cvec3 c2, cvec3 c3) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m20 = c2.x; this.m21 = c2.y; this.m22 = c2.z; this.m30 = c3.x; this.m31 = c3.y; this.m32 = c3.z; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat3x4(cvec3 c0, cvec3 c1, cvec3 c2) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m03 = Complex.Zero; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m13 = Complex.Zero; this.m20 = c2.x; this.m21 = c2.y; this.m22 = c2.z; this.m23 = Complex.Zero; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat4x3(cvec3 c0, cvec3 c1, cvec3 c2) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m20 = c2.x; this.m21 = c2.y; this.m22 = c2.z; this.m30 = Complex.Zero; this.m31 = Complex.Zero; this.m32 = Complex.Zero; }
/// <summary> /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix. /// </summary> public cmat4(cvec3 c0, cvec3 c1, cvec3 c2, cvec3 c3) { this.m00 = c0.x; this.m01 = c0.y; this.m02 = c0.z; this.m03 = Complex.Zero; this.m10 = c1.x; this.m11 = c1.y; this.m12 = c1.z; this.m13 = Complex.Zero; this.m20 = c2.x; this.m21 = c2.y; this.m22 = c2.z; this.m23 = Complex.Zero; this.m30 = c3.x; this.m31 = c3.y; this.m32 = c3.z; this.m33 = Complex.One; }
/// <summary> /// OuterProduct treats the first parameter c as a column vector (matrix with one column) and the second parameter r as a row vector (matrix with one row) and does a linear algebraic matrix multiply c * r, yielding a matrix whose number of rows is the number of components in c and whose number of columns is the number of components in r. /// </summary> public static cmat3x2 OuterProduct(cvec2 c, cvec3 r) => cvec2.OuterProduct(c, r);
/// <summary> /// Returns a bvec3 from component-wise application of Equal (lhs == rhs). /// </summary> public static bvec3 Equal(cvec3 lhs, cvec3 rhs) => cvec3.Equal(lhs, rhs);
/// <summary> /// Returns a bvec3 from component-wise application of NotEqual (lhs != rhs). /// </summary> public static bvec3 NotEqual(cvec3 lhs, cvec3 rhs) => cvec3.NotEqual(lhs, rhs);
/// <summary> /// Returns a hash code for this instance. /// </summary> public static int GetHashCode(cvec3 v) => v.GetHashCode();
/// <summary> /// Returns true iff distance between lhs and rhs is less than or equal to epsilon /// </summary> public static bool ApproxEqual(cvec3 lhs, cvec3 rhs, double eps = 0.1d) => cvec3.ApproxEqual(lhs, rhs, eps);
/// <summary> /// Returns a vector containing component-wise real parts. /// </summary> public static dvec3 Real(cvec3 v) => v.Real;
/// <summary> /// Returns true iff this equals rhs type- and component-wise. /// </summary> public static bool Equals(cvec3 v, object obj) => v.Equals(obj);
/// <summary> /// Returns a copy of this vector with length one (returns zero if length is zero). /// </summary> public static cvec3 NormalizedSafe(cvec3 v) => v.NormalizedSafe;
/// <summary> /// Returns the number of components (3). /// </summary> public static int Count(cvec3 v) => v.Count;
/// <summary> /// Returns a vector containing component-wise phases. /// </summary> public static dvec3 Phase(cvec3 v) => v.Phase;
/// <summary> /// Returns a vector containing component-wise magnitudes. /// </summary> public static dvec3 Magnitude(cvec3 v) => v.Magnitude;
/// <summary> /// Calculate the reflection direction for an incident vector (N should be normalized in order to achieve the desired result). /// </summary> public static cvec3 Reflect(cvec3 I, cvec3 N) => cvec3.Reflect(I, N);
/// <summary> /// Returns the squared euclidean distance between the two vectors. /// </summary> public static double DistanceSqr(cvec3 lhs, cvec3 rhs) => cvec3.DistanceSqr(lhs, rhs);
/// <summary> /// Returns the inner product (dot product, scalar product) of the two vectors. /// </summary> public static Complex Dot(cvec3 lhs, cvec3 rhs) => cvec3.Dot(lhs, rhs);
/// <summary> /// Returns a copy of this vector with length one (undefined if this has zero length). /// </summary> public static cvec3 Normalized(cvec3 v) => v.Normalized;
/// <summary> /// Returns true iff this equals rhs component-wise. /// </summary> public static bool Equals(cvec3 v, cvec3 rhs) => v.Equals(rhs);
/// <summary> /// Returns the outer product (cross product, vector product) of the two vectors. /// </summary> public static cvec3 Cross(cvec3 l, cvec3 r) => cvec3.Cross(l, r);
/// <summary> /// Returns a vector containing component-wise imaginary parts. /// </summary> public static dvec3 Imaginary(cvec3 v) => v.Imaginary;
/// <summary> /// Returns a string representation of this vector using a provided seperator and a format for each component. /// </summary> public static string ToString(cvec3 v, string sep, string format) => v.ToString(sep, format);
/// <summary> /// Returns a string representation of this vector using a provided seperator and a format and format provider for each component. /// </summary> public static string ToString(cvec3 v, string sep, string format, IFormatProvider provider) => v.ToString(sep, format, provider);