Struct double4x4
Represents a 4x4 Matrix typically used in ComputerGraphics algorithms.
Implements
Inherited Members
Namespace: Fusee.Math.Core
Assembly: Fusee.Math.Core.dll
Syntax
public struct double4x4 : IEquatable<double4x4>
Remarks
double4x4 objects represent matrices used in column-vector-notation, that means when used in common matrix-vector-multiplication scenarios, the vector should be multiplied from the right to the matrix (M * v). Concatenations of matrices from left to right represent a transformation where the rightmost matrix is applied first and the leftmost matrix is applied last, for example in (M3 * M2 * M1) * v the vector v is first transformed by M1, then by M2 and finally by M3. The translation part of a 4x4 matrix used in homogeneous coordinate calculations can be found in the leftmost column (M14 - x-translation, M24 - y-translation, M34 - z-translation).
Note that although double4x4 objects represent matrices in COLUMN-vector-NOTATION as found in math books, the objects' contents is physically stored in ROW-major-ORDER, meaning that in physical memory, a double4x4's components are stored contiguously in the following order: first row (M11, M12, M13, M14), then second row (M21, M22, M21, M24), and so on. When exchanging matrix contents with libraries like graphics engines (OpenGL, Direct3D), physics engines, file formats, etc. make sure to convert to and from the given Matrix layout of the API you are exchanging data with.
double4x4 contains convenience construction methods to create matrices commonly used in Computer Graphics. Most of these application matrices are handedness-agnostic, meaning that the resulting matrices can be used in both, left-handed and right-handed coordinate systems. This does not hold for LookAt and Projection matrices where the viewing direction plays a role. In left-handed coordinate systems the viewing direction is positive, meaning positions further away have bigger positive z-coordinates whereas in right-handed coordinate systems positions further away have smaller negative z-coordinates. By default, double4x4 will assume a left-handed coordinate system, but contains convenience construction methods to also create right-handed matrices if necessary. The right-handed versions of methods are postfixed with "RH".
Constructors
double4x4(double3x3)
Constructs a new double4x4 from a double3x3 by setting the 4th column and row to UnitW respectively.
Declaration
public double4x4(double3x3 f3x3)
Parameters
| Type | Name | Description |
|---|---|---|
| double3x3 | f3x3 | The double3x3 matrix to copy components from. |
double4x4(double4, double4, double4, double4)
Constructs a new instance.
Declaration
public double4x4(double4 row1, double4 row2, double4 row3, double4 row4)
Parameters
| Type | Name | Description |
|---|---|---|
| double4 | row1 | Top row of the matrix |
| double4 | row2 | Second row of the matrix |
| double4 | row3 | Third row of the matrix |
| double4 | row4 | Bottom row of the matrix |
double4x4(float4x4)
Constructs a new double4x4 by converting from a double4x4.
Declaration
public double4x4(float4x4 d4x4)
Parameters
| Type | Name | Description |
|---|---|---|
| float4x4 | d4x4 | The double4x4 to copy components from. |
double4x4(Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double)
Constructs a new instance.
Declaration
public double4x4(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | m11 | First item of the first row of the matrix. |
| System.Double | m12 | Second item of the first row of the matrix. |
| System.Double | m13 | Third item of the first row of the matrix. |
| System.Double | m14 | Fourth item of the first row of the matrix. |
| System.Double | m21 | First item of the second row of the matrix. |
| System.Double | m22 | Second item of the second row of the matrix. |
| System.Double | m23 | Third item of the second row of the matrix. |
| System.Double | m24 | Fourth item of the second row of the matrix. |
| System.Double | m31 | First item of the third row of the matrix. |
| System.Double | m32 | Second item of the third row of the matrix. |
| System.Double | m33 | Third item of the third row of the matrix. |
| System.Double | m34 | First item of the third row of the matrix. |
| System.Double | m41 | Fourth item of the fourth row of the matrix. |
| System.Double | m42 | Second item of the fourth row of the matrix. |
| System.Double | m43 | Third item of the fourth row of the matrix. |
| System.Double | m44 | Fourth item of the fourth row of the matrix. |
Fields
Identity
The identity matrix
Declaration
public static readonly double4x4 Identity
Field Value
| Type | Description |
|---|---|
| double4x4 |
Row1
Top row of the matrix
Declaration
public double4 Row1
Field Value
| Type | Description |
|---|---|
| double4 |
Row2
2nd row of the matrix
Declaration
public double4 Row2
Field Value
| Type | Description |
|---|---|
| double4 |
Row3
3rd row of the matrix
Declaration
public double4 Row3
Field Value
| Type | Description |
|---|---|
| double4 |
Row4
Bottom row of the matrix
Declaration
public double4 Row4
Field Value
| Type | Description |
|---|---|
| double4 |
Zero
The zero matrix
Declaration
public static readonly double4x4 Zero
Field Value
| Type | Description |
|---|---|
| double4x4 |
Properties
Column1
The first column of this matrix
Declaration
public double4 Column1 { get; set; }
Property Value
| Type | Description |
|---|---|
| double4 |
Column2
The second column of this matrix
Declaration
public double4 Column2 { get; set; }
Property Value
| Type | Description |
|---|---|
| double4 |
Column3
The third column of this matrix
Declaration
public double4 Column3 { get; set; }
Property Value
| Type | Description |
|---|---|
| double4 |
Column4
The fourth column of this matrix
Declaration
public double4 Column4 { get; set; }
Property Value
| Type | Description |
|---|---|
| double4 |
Determinant
The determinant of this matrix
Declaration
public readonly double Determinant { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
IsAffine
Checks whether row three (the projection part) of the matrix is equal to (0, 0, 0, 1). If this is the case the matrix is affine.
Declaration
public readonly bool IsAffine { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[Int32, Int32]
Sets/Gets value from given index
Declaration
public double this[int i, int j] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | i | The ROW index |
| System.Int32 | j | The COLUMN index |
Property Value
| Type | Description |
|---|---|
| System.Double |
M11
Gets and sets the value at row 1, column 1 of this instance.
Declaration
public double M11 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M12
Gets and sets the value at row 1, column 2 of this instance.
Declaration
public double M12 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M13
Gets and sets the value at row 1, column 3 of this instance.
Declaration
public double M13 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M14
Gets and sets the value at row 1, column 4 of this instance.
Declaration
public double M14 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M21
Gets and sets the value at row 2, column 1 of this instance.
Declaration
public double M21 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M22
Gets and sets the value at row 2, column 2 of this instance.
Declaration
public double M22 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M23
Gets and sets the value at row 2, column 3 of this instance.
Declaration
public double M23 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M24
Gets and sets the value at row 2, column 4 of this instance.
Declaration
public double M24 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M31
Gets and sets the value at row 3, column 1 of this instance.
Declaration
public double M31 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M32
Gets and sets the value at row 3, column 2 of this instance.
Declaration
public double M32 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M33
Gets and sets the value at row 3, column 3 of this instance.
Declaration
public double M33 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M34
Gets and sets the value at row 3, column 4 of this instance.
Declaration
public double M34 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M41
Gets and sets the value at row 4, column 1 of this instance.
Declaration
public double M41 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M42
Gets and sets the value at row 4, column 2 of this instance.
Declaration
public double M42 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M43
Gets and sets the value at row 4, column 3 of this instance.
Declaration
public double M43 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M44
Gets and sets the value at row 4, column 4 of this instance.
Declaration
public double M44 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Offset
Gets the offset part of the matrix as a double3 instance.
Declaration
public readonly double3 Offset { get; }
Property Value
| Type | Description |
|---|---|
| double3 |
Remarks
The offset part of the matrix consists of the M14, M24 and M34 components (in row major order notation).
ParseConverter
Gets and sets the Converter object. Has the ability to convert a string to a double4x4.
Declaration
public static Converter<string, double4x4> ParseConverter { get; set; }
Property Value
| Type | Description |
|---|---|
| Converter<System.String, double4x4> | The parse property. |
Trace
Returns the trace of this matrix
Declaration
public readonly double Trace { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Methods
Add(in double4x4, in double4x4)
Adds two instances.
Declaration
public static double4x4 Add(in double4x4 left, in double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | The left operand of the addition. |
| double4x4 | right | The right operand of the addition. |
Returns
| Type | Description |
|---|---|
| double4x4 | A new instance that is the result of the addition. |
CreateFromAxisAngle(double3, Double)
Build a rotation matrix from the specified axis/angle rotation.
Declaration
public static double4x4 CreateFromAxisAngle(double3 axis, double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | axis | The axis to rotate about. |
| System.Double | angle | Angle to rotate counter-clockwise (looking in the direction of the given axis). |
Returns
| Type | Description |
|---|---|
| double4x4 | A matrix instance. |
CreateOrthographic(Double, Double, Double, Double)
Creates a left handed orthographic projection matrix.
Declaration
public static double4x4 CreateOrthographic(double width, double height, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | The width of the projection volume. |
| System.Double | height | The height of the projection volume. |
| System.Double | zNear | The near edge of the projection volume. |
| System.Double | zFar | The far edge of the projection volume. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateOrthographicOffCenter(Double, Double, Double, Double, Double, Double)
Creates a left handed orthographic projection matrix.
Declaration
public static double4x4 CreateOrthographicOffCenter(double left, double right, double bottom, double top, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | left | The left edge of the projection volume. |
| System.Double | right | The right edge of the projection volume. |
| System.Double | bottom | The bottom edge of the projection volume. |
| System.Double | top | The top edge of the projection volume. |
| System.Double | zNear | The near edge of the projection volume. |
| System.Double | zFar | The far edge of the projection volume. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateOrthographicOffCenterRH(Double, Double, Double, Double, Double, Double)
Creates a right handed orthographic projection matrix.
Declaration
public static double4x4 CreateOrthographicOffCenterRH(double left, double right, double bottom, double top, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | left | The left edge of the projection volume. |
| System.Double | right | The right edge of the projection volume. |
| System.Double | bottom | The bottom edge of the projection volume. |
| System.Double | top | The top edge of the projection volume. |
| System.Double | zNear | The near edge of the projection volume. |
| System.Double | zFar | The far edge of the projection volume. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreatePerspectiveFieldOfView(Double, Double, Double, Double)
Creates a left handed perspective projection matrix.
Declaration
public static double4x4 CreatePerspectiveFieldOfView(double fovy, double aspect, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | fovy | Angle of the field of view in the y direction (in radians) |
| System.Double | aspect | Aspect ratio of the view (width / height) |
| System.Double | zNear | Distance to the near clip plane |
| System.Double | zFar | Distance to the far clip plane |
Returns
| Type | Description |
|---|---|
| double4x4 | A projection matrix that transforms camera space to raster space |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
CreatePerspectiveOffCenter(Double, Double, Double, Double, Double, Double)
Creates an left handed perspective projection matrix.
Declaration
public static double4x4 CreatePerspectiveOffCenter(double left, double right, double bottom, double top, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | left | Left edge of the view frustum |
| System.Double | right | Right edge of the view frustum |
| System.Double | bottom | Bottom edge of the view frustum |
| System.Double | top | Top edge of the view frustum |
| System.Double | zNear | Distance to the near clip plane |
| System.Double | zFar | Distance to the far clip plane |
Returns
| Type | Description |
|---|---|
| double4x4 | A projection matrix that transforms camera space to raster space |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
CreatePerspectiveOffCenterRH(Double, Double, Double, Double, Double, Double)
Creates a right handed perspective projection matrix.
Declaration
public static double4x4 CreatePerspectiveOffCenterRH(double left, double right, double bottom, double top, double zNear, double zFar)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | left | Left edge of the view frustum |
| System.Double | right | Right edge of the view frustum |
| System.Double | bottom | Bottom edge of the view frustum |
| System.Double | top | Top edge of the view frustum |
| System.Double | zNear | Distance to the near clip plane |
| System.Double | zFar | Distance to the far clip plane |
Returns
| Type | Description |
|---|---|
| double4x4 | A right handed projection matrix that transforms camera space to raster space |
Remarks
Generates a matrix mapping a frustum shaped volume (the viewing frustum) to the unit cube (ranging from -1 to 1 in each dimension, also in z). The sign of the z-value will be flipped for vectors multiplied with this matrix. Given that the underlying rendering platform interprets z-values returned by the vertex shader to be in left-handed coordinates, where increasing z-values indicate locations further away from the view point (as BOTH, Direct3D AND OpenGL do), this type of matrix is widely called to be a "right handed" projection matrix as it assumes a right-handed camera coordinate system.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
CreateRotationX(Double)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
public static double4x4 CreateRotationX(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateRotationXY(double2)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationXY(double2 xy)
Parameters
| Type | Name | Description |
|---|---|---|
| double2 | xy | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationXY(Double, Double)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationXY(double x, double y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | counter-clockwise angles in radians. |
| System.Double | y | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationY(Double)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
public static double4x4 CreateRotationY(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateRotationZ(Double)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
public static double4x4 CreateRotationZ(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateRotationZX(double2)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationZX(double2 xz)
Parameters
| Type | Name | Description |
|---|---|---|
| double2 | xz | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationZX(Double, Double)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationZX(double x, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | counter-clockwise angles in radians. |
| System.Double | z | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationZXY(double3)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationZXY(double3 xyz)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | xyz | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationZXY(Double, Double, Double)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationZXY(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | counter-clockwise angles in radians. |
| System.Double | y | counter-clockwise angles in radians. |
| System.Double | z | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationZY(double2)
Builds a rotation matrix for a rotation around the y and z-axis.
Declaration
public static double4x4 CreateRotationZY(double2 yz)
Parameters
| Type | Name | Description |
|---|---|---|
| double2 | yz | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateRotationZY(Double, Double)
Builds a rotation matrix for a rotation around the y and x-axis.
Declaration
public static double4x4 CreateRotationZY(double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | y | counter-clockwise angles in radians. |
| System.Double | z | counter-clockwise angles in radians. |
Returns
| Type | Description |
|---|---|
| double4x4 |
CreateScale(double3)
Creates a scale matrix.
Declaration
public static double4x4 CreateScale(double3 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | vector | The scale vector. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateScale(Double)
Creates a uniform scale matrix with the same scale value along all three dimensions.
Declaration
public static double4x4 CreateScale(double scale)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | scale | The value to scale about x, y, and z. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateScale(Double, Double, Double)
Creates a scale matrix.
Declaration
public static double4x4 CreateScale(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | X scale. |
| System.Double | y | Y scale. |
| System.Double | z | Z scale. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateTranslation(double3)
Creates a translation matrix.
Declaration
public static double4x4 CreateTranslation(double3 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | vector | The translation vector. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
CreateTranslation(Double, Double, Double)
Creates a translation matrix.
Declaration
public static double4x4 CreateTranslation(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | X translation. |
| System.Double | y | Y translation. |
| System.Double | z | Z translation. |
Returns
| Type | Description |
|---|---|
| double4x4 | The resulting double4x4 instance. |
Equals(double4x4)
Indicates whether the current matrix is equal to another matrix.
Declaration
public readonly bool Equals(double4x4 other)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | other | A matrix to compare with this matrix. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the current matrix is equal to the matrix parameter; otherwise, false. |
Equals(Object)
Indicates whether this instance and a specified object are equal.
Declaration
public override readonly bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The object to compare the result. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instances are equal; false otherwise. |
Overrides
GetHashCode()
Returns the hashcode for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A System.Int32 containing the unique hashcode for this instance. |
Overrides
GetScale(double4x4)
Calculates the scale factor of the given double4x4 and returns it as a double3 vector.
Declaration
public static double3 GetScale(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat |
Returns
| Type | Description |
|---|---|
| double3 |
GetTranslation(double4x4)
Calculates translation of the given double4x4 matrix and returns it as a double3 vector.
Declaration
public static double3 GetTranslation(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat |
Returns
| Type | Description |
|---|---|
| double3 |
Invert()
Converts this instance into its inverse.
Declaration
public double4x4 Invert()
Returns
| Type | Description |
|---|---|
| double4x4 |
Invert(in double4x4)
Calculate the inverse of the given matrix. If you are unsure whether the matrix is invertible, check it with IsInvertable() first.
Declaration
public static double4x4 Invert(in double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | The matrix to invert. |
Returns
| Type | Description |
|---|---|
| double4x4 | The inverse of the given matrix. |
IsInvertable(double4x4)
Checks if this matrix is invertible.
Declaration
public static bool IsInvertable(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat | The matrix. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsInvertable(double4x4, out Double)
Checks if this matrix is invertible.
Declaration
public static bool IsInvertable(double4x4 mat, out double det)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat | The matrix. |
| System.Double | det | The determinant of the matrix. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
LookAt(double3, double3, double3)
Build a left handed world space to camera space matrix
Declaration
public static double4x4 LookAt(double3 eye, double3 target, double3 up)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | eye | Eye (camera) position in world space |
| double3 | target | Target position in world space |
| double3 | up | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
Returns
| Type | Description |
|---|---|
| double4x4 | A Matrix4 that transforms world space to camera space |
LookAt(Double, Double, Double, Double, Double, Double, Double, Double, Double)
Build a world space to camera space matrix
Declaration
public static double4x4 LookAt(double eyeX, double eyeY, double eyeZ, double targetX, double targetY, double targetZ, double upX, double upY, double upZ)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | eyeX | Eye (camera) position in world space |
| System.Double | eyeY | Eye (camera) position in world space |
| System.Double | eyeZ | Eye (camera) position in world space |
| System.Double | targetX | Target position in world space |
| System.Double | targetY | Target position in world space |
| System.Double | targetZ | Target position in world space |
| System.Double | upX | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
| System.Double | upY | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
| System.Double | upZ | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
Returns
| Type | Description |
|---|---|
| double4x4 | A double4x4 that transforms world space to camera space |
LookAtRH(double3, double3, double3)
Build a right handed world space to camera space matrix
Declaration
public static double4x4 LookAtRH(double3 eye, double3 target, double3 up)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | eye | Eye (camera) position in world space |
| double3 | target | Target position in world space |
| double3 | up | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
Returns
| Type | Description |
|---|---|
| double4x4 | A double4x4 that transforms world space to camera space |
Mult(in double4x4, in double4x4)
Multiplies two instances.
Declaration
public static double4x4 Mult(in double4x4 left, in double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | The left operand of the multiplication. |
| double4x4 | right | The right operand of the multiplication. |
Returns
| Type | Description |
|---|---|
| double4x4 | A new instance that is the result of the multiplication |
Parse(String, IFormatProvider)
Parses a string into a double4x4.
Declaration
public static double4x4 Parse(string source, IFormatProvider provider = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source | |
| System.IFormatProvider | provider |
Returns
| Type | Description |
|---|---|
| double4x4 |
RotationComponent()
The rotation component of this matrix.
Declaration
public double4x4 RotationComponent()
Returns
| Type | Description |
|---|---|
| double4x4 |
RotationDecomposition(double4x4)
Calculates and returns the rotation component of the given double4x4 matrix.
Declaration
public static double4x4 RotationDecomposition(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat |
Returns
| Type | Description |
|---|---|
| double4x4 |
RotMatToEuler(double4x4)
Returns the euler angles from a given rotation matrix.
Declaration
public static double3 RotMatToEuler(double4x4 rotMat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | rotMat | The rotation matrix. |
Returns
| Type | Description |
|---|---|
| double3 |
Round()
Rounds this instance to 6 digits (max double precision).
Declaration
public double4x4 Round()
Returns
| Type | Description |
|---|---|
| double4x4 |
Round(double4x4)
Rounds the given matrix to 6 digits (max double precision).
Declaration
public static double4x4 Round(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat | The matrix to round. |
Returns
| Type | Description |
|---|---|
| double4x4 | The rounded matrix. |
Scale()
The scale factors of this matrix.
Declaration
public double3 Scale()
Returns
| Type | Description |
|---|---|
| double3 |
Scale(double3)
Build a scaling matrix
Declaration
public static double4x4 Scale(double3 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | scale | Scale factors for x,y and z axes |
Returns
| Type | Description |
|---|---|
| double4x4 | A scaling matrix |
Scale(Double)
Build a scaling matrix
Declaration
public static double4x4 Scale(double scale)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | scale | Single scale factor for x,y and z axes |
Returns
| Type | Description |
|---|---|
| double4x4 | A scaling matrix |
Scale(Double, Double, Double)
Build a scaling matrix
Declaration
public static double4x4 Scale(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | Scale factor for x-axis |
| System.Double | y | Scale factor for y-axis |
| System.Double | z | Scale factor for z-axis |
Returns
| Type | Description |
|---|---|
| double4x4 | A scaling matrix |
ScaleComponent()
The scale component of this matrix.
Declaration
public double4x4 ScaleComponent()
Returns
| Type | Description |
|---|---|
| double4x4 |
ScaleDecomposition(double4x4)
Calculates and returns the scale component of the given double4x4 matrix.
Declaration
public static double4x4 ScaleDecomposition(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat |
Returns
| Type | Description |
|---|---|
| double4x4 |
Subtract(in double4x4, in double4x4)
Subtracts the right instance from the left instance.
Declaration
public static double4x4 Subtract(in double4x4 left, in double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | The left operand of the subtraction. |
| double4x4 | right | The right operand of the subtraction. |
Returns
| Type | Description |
|---|---|
| double4x4 | A new instance that is the result of the subtraction. |
ToArray()
Returns the matrix as double array.
Declaration
public double[] ToArray()
Returns
| Type | Description |
|---|---|
| System.Double[] |
ToString()
Returns a System.String that represents the current double4x4.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents the current double4x4.
Declaration
public string ToString(IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | provider | Provides information about a specific culture. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Transform(double4x4, double3)
Transforms a given 3D vector by a matrix using perspective division via matrix*vector (Postmultiplication of the vector).
Declaration
public static double3 Transform(double4x4 matrix, double3 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | A double4x4 instance. |
| double3 | vector | A double3 instance. |
Returns
| Type | Description |
|---|---|
| double3 | A new double3 instance containing the result. |
Remarks
Before the matrix multiplication the 3D vector is extended to 4D by setting its W component to 1. After the matrix multiplication the resulting 4D vector is transformed to 3D by dividing X, Y, and Z by W. (perspective division).
Transform(double4x4, double4)
Transforms a given vector by a matrix via matrix*vector (Postmultiplication of the vector).
Declaration
public static double4 Transform(double4x4 matrix, double4 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | A double4x4 instance. |
| double4 | vector | A double4 instance. |
Returns
| Type | Description |
|---|---|
| double4 | A new double4 instance containing the result. |
TransformPerspective(double4x4, double3)
Transforms a given 3D vector by a matrix, and projects the resulting double4 back to a double3.
Declaration
public static double3 TransformPerspective(double4x4 mat, double3 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat | The desired transformation matrix. |
| double3 | vec | The given vector. |
Returns
| Type | Description |
|---|---|
| double3 | The transformed vector. |
TransformPerspective(double4x4, double4)
Transforms the given vector by the given matrix and applies a perspective division.
Declaration
public static double4 TransformPerspective(double4x4 mat, double4 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat | The desired transformation. |
| double4 | vec | The given vector. |
Returns
| Type | Description |
|---|---|
| double4 | The transformed vector. |
TransformPremult(double3, double4x4)
Transforms a given 3D vector by a matrix using perspective division via vector*matrix (Premultiplication of the vector).
Declaration
public static double3 TransformPremult(double3 vector, double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | vector | A double3 instance. |
| double4x4 | matrix | A double4x4 instance. |
Returns
| Type | Description |
|---|---|
| double3 | A new double3 instance containing the result. |
Remarks
Before the matrix multiplication the 3D vector is extended to 4D by setting its W component to 1. After the matrix multiplication the resulting 4D vector is transformed to 3D by dividing X, Y, and Z by W. (perspective division).
TransformPremult(double4, double4x4)
Transforms a given vector by a matrix via vector*matrix (Premultiplication of the vector).
Declaration
public static double4 TransformPremult(double4 vector, double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double4 | vector | A double4 instance. |
| double4x4 | matrix | A double4x4 instance. |
Returns
| Type | Description |
|---|---|
| double4 | A new double4 instance containing the result. |
Translation()
The translation of this matrix.
Declaration
public double3 Translation()
Returns
| Type | Description |
|---|---|
| double3 |
TranslationComponent()
The translation component of this matrix.
Declaration
public double4x4 TranslationComponent()
Returns
| Type | Description |
|---|---|
| double4x4 |
TranslationDecomposition(double4x4)
Calculates and returns only the translation component of the given double4x4 matrix.
Declaration
public static double4x4 TranslationDecomposition(double4x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | mat |
Returns
| Type | Description |
|---|---|
| double4x4 |
Transpose()
Converts this instance into its transpose.
Declaration
public double4x4 Transpose()
Returns
| Type | Description |
|---|---|
| double4x4 |
Transpose(double4x4)
Calculate the transpose of the given matrix
Declaration
public static double4x4 Transpose(double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | The matrix to transpose |
Returns
| Type | Description |
|---|---|
| double4x4 | The transpose of the given matrix |
Operators
Addition(double4x4, double4x4)
Matrix addition
Declaration
public static double4x4 operator +(double4x4 left, double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | left-hand operand |
| double4x4 | right | right-hand operand |
Returns
| Type | Description |
|---|---|
| double4x4 | A new double4x4 which holds the result of the multiplication |
Equality(double4x4, double4x4)
Compares two instances for equality.
Declaration
public static bool operator ==(double4x4 left, double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | The first instance. |
| double4x4 | right | The second instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True, if left equals right; false otherwise. |
Explicit(float4x4 to double4x4)
Explicit cast operator to cast a double4x4 into a double4x4 value.
Declaration
public static explicit operator double4x4(float4x4 d4x4)
Parameters
| Type | Name | Description |
|---|---|---|
| float4x4 | d4x4 | The double4x4 value to cast. |
Returns
| Type | Description |
|---|---|
| double4x4 | A double4x4 value. |
Inequality(double4x4, double4x4)
Compares two instances for inequality.
Declaration
public static bool operator !=(double4x4 left, double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | The first instance. |
| double4x4 | right | The second instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True, if left does not equal right; false otherwise. |
Multiply(double3, double4x4)
Transforms a given three dimensional vector by a matrix via vector*matrix (pre-multiplication of the vector).
Declaration
public static double3 operator *(double3 vector, double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double3 | vector | A double3 instance. |
| double4x4 | matrix | A double4x4 instance. |
Returns
| Type | Description |
|---|---|
| double3 | A new double4 instance containing the result. |
Remarks
Before the matrix multiplication the 3D vector is extended to 4D by setting its W component to 1. After the matrix multiplication the resulting 4D vector is transformed to 3D by dividing X, Y, and Z by W. (perspective division).
Multiply(double4, double4x4)
Transforms a given vector by a matrix via vector*matrix (pre-multiplication of the vector).
Declaration
public static double4 operator *(double4 vector, double4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| double4 | vector | A double4 instance. |
| double4x4 | matrix | A double4x4 instance. |
Returns
| Type | Description |
|---|---|
| double4 | A new double4 instance containing the result. |
Multiply(double4x4, double3)
Transforms a given three dimensional vector by a matrix via matrix*vector (post-multiplication of the vector).
Declaration
public static double3 operator *(double4x4 matrix, double3 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | A double4x4 instance. |
| double3 | vector | A double3 instance. |
Returns
| Type | Description |
|---|---|
| double3 | A new double4 instance containing the result. |
Remarks
Before the matrix multiplication the 3D vector is extended to 4D by setting its W component to 1. After the matrix multiplication the resulting 4D vector is transformed to 3D by dividing X, Y, and Z by W. (perspective division).
Multiply(double4x4, double4)
Transforms a given vector by a matrix via matrix*vector (post-multiplication of the vector).
Declaration
public static double4 operator *(double4x4 matrix, double4 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | matrix | A double4x4 instance. |
| double4 | vector | A double4 instance. |
Returns
| Type | Description |
|---|---|
| double4 | A new double4 instance containing the result. |
Multiply(double4x4, double4x4)
Matrix multiplication
Declaration
public static double4x4 operator *(double4x4 left, double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | left-hand operand |
| double4x4 | right | right-hand operand |
Returns
| Type | Description |
|---|---|
| double4x4 | A new Matrix44 which holds the result of the multiplication |
Subtraction(double4x4, double4x4)
Matrix subtraction
Declaration
public static double4x4 operator -(double4x4 left, double4x4 right)
Parameters
| Type | Name | Description |
|---|---|---|
| double4x4 | left | left-hand operand |
| double4x4 | right | right-hand operand |
Returns
| Type | Description |
|---|---|
| double4x4 | A new double2x2 which holds the result of the multiplication |