A 4x4 matrix with 64-bit floating-point precision.
struct
|
Mat4D
|
implements
|
IEquatable<Mat4D>
|
/ \ | M11 M12 M13 M14 | | M21 M22 M23 M24 | | M31 M32 M33 M34 | | M41 M42 M43 M44 | \ /
Returns the determinant of this matrix.
public
property
|
Determinant
{
get
}
|
||
type
|
float64
|
||
value
|
The determinant value. |
Returns the inverse of this matrix.
public
property
|
Inverse
{
get
}
|
||
type
|
Mat4D
|
||
value
|
The inverse matrix. |
Matrix component in first row, first column.
public
readonly
field
|
M11
|
||
type
|
float64
|
Matrix component in first row, second column.
public
readonly
field
|
M12
|
||
type
|
float64
|
Matrix component in first row, third column.
public
readonly
field
|
M13
|
||
type
|
float64
|
Matrix component in first row, fourth column.
public
readonly
field
|
M14
|
||
type
|
float64
|
Matrix component in second row, first column.
public
readonly
field
|
M21
|
||
type
|
float64
|
Matrix component in second row, second column.
public
readonly
field
|
M22
|
||
type
|
float64
|
Matrix component in second row, third column.
public
readonly
field
|
M23
|
||
type
|
float64
|
Matrix component in second row, fourth column.
public
readonly
field
|
M24
|
||
type
|
float64
|
Matrix component in third row, first column.
public
readonly
field
|
M31
|
||
type
|
float64
|
Matrix component in third row, second column.
public
readonly
field
|
M32
|
||
type
|
float64
|
Matrix component in third row, third column.
public
readonly
field
|
M33
|
||
type
|
float64
|
Matrix component in third row, fourth column.
public
readonly
field
|
M34
|
||
type
|
float64
|
Matrix component in fourth row, first column.
public
readonly
field
|
M41
|
||
type
|
float64
|
Matrix component in fourth row, second column.
public
readonly
field
|
M42
|
||
type
|
float64
|
Matrix component in fourth row, third column.
public
readonly
field
|
M43
|
||
type
|
float64
|
Matrix component in fourth row, fourth column.
public
readonly
field
|
M44
|
||
type
|
float64
|
Returns the transpose of this matrix.
public
property
|
Transpose
{
get
}
|
||
type
|
Mat4D
|
||
value
|
The transposed matrix. |
The identity matrix.
public
static
readonly
field
|
Identity
|
||
type
|
Mat4D
|
The zero matrix.
public
static
readonly
field
|
Zero
|
||
type
|
Mat4D
|
Creates a new instance of Mat4D.
[Pure]
|
||||
public
static
method
|
FromColumns
(Vec4D col1,
Vec4D col2,
Vec4D col3,
Vec4D col4)
|
|||
type
|
Mat4D
|
|||
params
|
col1
|
The first column vector. | ||
col2
|
The second column vector. | |||
col3
|
The third column vector. | |||
col4
|
The fourth column vector. | |||
returns
|
The matrix. |
Creates a new instance of Mat4D.
[Pure]
|
||||
public
static
method
|
FromRows
(Vec4D row1,
Vec4D row2,
Vec4D row3,
Vec4D row4)
|
|||
type
|
Mat4D
|
|||
params
|
row1
|
The first row vector. | ||
row2
|
The second row vector. | |||
row3
|
The third row vector. | |||
row4
|
The fourth row vector. | |||
returns
|
The matrix. |
Creates a look-at transformation matrix.
[Pure]
|
||||
public
static
method
|
LookAt
(Vec3D origin,
Vec3D target,
Vec3D up,
bool rightHanded)
|
|||
type
|
Mat4D
|
|||
params
|
origin
|
The origin position. | ||
target
|
The look-at position. | |||
up
|
The up-direction vector. | |||
rightHanded
|
true
to
create
a
right-handed
coordinate
system,
false
to
create
a
left-handed
one.
|
|||
returns
|
The transformation matrix. |
Creates a new instance of Mat4D.
public
constructor
|
Mat4D
(float64 m11,
float64 m12,
float64 m13,
float64 m14,
float64 m21,
float64 m22,
float64 m23,
float64 m24,
float64 m31,
float64 m32,
float64 m33,
float64 m34,
float64 m41,
float64 m42,
float64 m43,
float64 m44)
|
||
params
|
m11
|
Matrix component in first row, first column. | |
m12
|
Matrix component in first row, second column. | ||
m13
|
Matrix component in first row, third column. | ||
m14
|
Matrix component in first row, fourth column. | ||
m21
|
Matrix component in second row, first column. | ||
m22
|
Matrix component in second row, second column. | ||
m23
|
Matrix component in second row, third column. | ||
m24
|
Matrix component in second row, fourth column. | ||
m31
|
Matrix component in third row, first column. | ||
m32
|
Matrix component in third row, second column. | ||
m33
|
Matrix component in third row, third column. | ||
m34
|
Matrix component in third row, fourth column. | ||
m41
|
Matrix component in fourth row, first column. | ||
m42
|
Matrix component in fourth row, second column. | ||
m43
|
Matrix component in fourth row, third column. | ||
m44
|
Matrix component in fourth row, fourth column. |
Creates an orthographic projection matrix.
[Pure]
|
||||
public
static
method
|
Orthographic
(float64 left,
float64 right,
float64 top,
float64 bottom,
float64 zNear,
float64 zFar,
bool nearAtZero)
|
|||
type
|
Mat4D
|
|||
params
|
left
|
The
X-coordinate
to
map
to
-1 . |
||
right
|
The
X-coordinate
to
map
to
+1 . |
|||
top
|
The
Y-coordinate
to
map
to
-1 . |
|||
bottom
|
The
Y-coordinate
to
map
to
+1 . |
|||
zNear
|
The
Z-coordinate
to
map
to
0
resp.
-1 . |
|||
zFar
|
The
Z-coordinate
to
map
to
+1 . |
|||
nearAtZero
|
true
to
map
zNear
to
0 ,
false
to
map
zNear
to
-1 .
|
|||
returns
|
The projection matrix. |
Creates a perspective projection matrix.
[Pure]
|
||||
public
static
method
|
PerspectiveFov
(float64 fov,
float64 aspect,
float64 n,
float64 f,
bool nearAtZero,
bool rightHanded)
|
|||
type
|
Mat4D
|
|||
params
|
fov
|
The field-of-view along the viewport Y-axis, in radians. | ||
aspect
|
The viewport aspect ratio (width divided by height). | |||
n
|
Near
clipping
plane
Z-value
(will
be
mapped
to
0
resp.
-1
in
clip-space;
see
nearAtZero
for
details).
|
|||
f
|
Far
clipping
plane
Z-value
(will
be
mapped
to
1
in
clip-space).
|
|||
nearAtZero
|
When
true ,
the
near
clipping
plane
will
be
mapped
to
0
in
clip-space
(e.g.
Direct3D);
when
false
it
will
be
mapped
to
-1
(e.g.
OpenGL).
|
|||
rightHanded
|
Create
projection
matrix
for
a
right-handed
(true )
or
left-handed
(false )
coordinate
system?
|
|||
returns
|
The projection matrix. |
Returns a rotation matrix (counter-clockwise around the given axis for right-handed coordinate system).
[Pure]
|
||||
public
static
method
|
Rotate
(Vec3D axis,
float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
axis
|
Unit-length rotation axis vector. | ||
angle
|
The rotation angle, in radians. | |||
returns
|
The resulting matrix. |
Returns a rotation matrix (counter-clockwise around the given axis for right-handed coordinate system).
[Pure]
|
||||
public
static
method
|
Rotate
(float64 x,
float64 y,
float64 z,
float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
x
|
X-component of unit-length rotation axis vector. | ||
y
|
Y-component of unit-length rotation axis vector. | |||
z
|
Z-component of unit-length rotation axis vector. | |||
angle
|
The rotation angle, in radians. | |||
returns
|
The resulting matrix. |
Returns a rotation matrix (counter-clockwise around X-axis for right-handed coordinate system).
[Pure]
|
||||
public
static
method
|
RotateX
(float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
angle
|
The rotation angle, in radians. | ||
returns
|
The resulting matrix. |
Returns a rotation matrix (counter-clockwise around Y-axis for right-handed coordinate system).
[Pure]
|
||||
public
static
method
|
RotateY
(float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
angle
|
The rotation angle, in radians. | ||
returns
|
The resulting matrix. |
Returns a rotation matrix (counter-clockwise around Z-axis for right-handed coordinate system).
[Pure]
|
||||
public
static
method
|
RotateZ
(float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
angle
|
The rotation angle, in radians. | ||
returns
|
The resulting matrix. |
Returns a scaling matrix.
[Pure]
|
||||
public
static
method
|
Scale
(float64 f)
|
|||
type
|
Mat4D
|
|||
params
|
f
|
The scale factor. | ||
returns
|
The resulting matrix. |
Returns a scaling matrix.
[Pure]
|
||||
public
static
method
|
Scale
(Vec4D f)
|
|||
type
|
Mat4D
|
|||
params
|
f
|
The scale factors. | ||
returns
|
The resulting matrix. |
Returns a scaling matrix.
[Pure]
|
||||
public
static
method
|
Scale
(float64 fx,
float64 fy,
float64 fz,
float64 fw)
|
|||
type
|
Mat4D
|
|||
params
|
fx
|
The scale factor along the X-axis. | ||
fy
|
The scale factor along the Y-axis. | |||
fz
|
The scale factor along the Z-axis. | |||
fw
|
The scale factor along the W-axis. | |||
returns
|
The resulting matrix. |
Returns a translation matrix.
[Pure]
|
||||
public
static
method
|
Translate
(Vec3D v)
|
|||
type
|
Mat4D
|
|||
params
|
v
|
The translation vector. | ||
returns
|
The translation matrix. |
Returns a translation matrix.
[Pure]
|
||||
public
static
method
|
Translate
(float64 x,
float64 y,
float64 z)
|
|||
type
|
Mat4D
|
|||
params
|
x
|
X-component of translation vector. | ||
y
|
Y-component of translation vector. | |||
z
|
Z-component of translation vector. | |||
returns
|
The translation matrix. |
Computes an invertible 3D homogeneous warp matrix that transforms the given source triangle onto the specified target triangle.
[Pure]
|
||||
public
static
method
|
Warp
(Vec3D a0,
Vec3D b0,
Vec3D c0,
Vec3D a1,
Vec3D b1,
Vec3D c1)
|
|||
type
|
Mat4D
|
|||
params
|
a0
|
First vertex of source triangle. | ||
b0
|
Second vertex of source triangle. | |||
c0
|
Third vertex of source triangle. | |||
a1
|
First vertex of target triangle. | |||
b1
|
Second vertex of target triangle. | |||
c1
|
Third vertex of target triangle. | |||
returns
|
The homogeneous 3D warp matrix. |
Remarks:
The
fourth
row
of
the
returned
matrix
will
always
be
(0,0,0,1)
,
so
it
is
not
necessary
to
perform
the
homogeneous
divide.
Also
all
elements
along
the
main
diagonal
will
be
1
.
Decomposes this matrix into a reduced matrix without translational components and an offset vector.
[Pure]
|
||||
public
method
|
DecomposeTranslation
(out Mat4D reduced,
out Vec3D offset)
|
|||
params
|
reduced
|
Output of reduced matrix. | ||
offset
|
Output
of
transformed
offset
vector
(see
O
above). |
Compares this object with the given one.
[Pure]
|
||||
public
method
|
Equals
(Mat4D other)
|
|||
type
|
bool
|
|||
params
|
other
|
The object to compare to. | ||
returns
|
true
if
this
object
is
equal
to
other,
false
if
not.
|
Checks if this matrix and the given one are similar but necessarily equal.
[Pure]
|
||||
public
method
|
EqualsAlmost
(Mat4D other)
|
|||
type
|
bool
|
|||
params
|
other
|
The other matrix. | ||
returns
|
true
if
both
matrices
are
similar,
false
if
they
are
not. |
See also:
Maths.SimilarReturns a column vector.
[Pure]
|
||||
public
method
|
GetColumn
(int32 index)
|
|||
type
|
Vec4D
|
|||
params
|
index
|
The zero-based column index. | ||
returns
|
The column vector. |
Returns a row vector.
[Pure]
|
||||
public
method
|
GetRow
(int32 index)
|
|||
type
|
Vec4D
|
|||
params
|
index
|
The zero-based row index. | ||
returns
|
The row vector. |
Performs a component-wise linear interpolation between this matrix and the given one.
[Pure]
|
||||
public
method
|
Lerp
(Mat4D other,
float64 factor)
|
|||
type
|
Mat4D
|
|||
params
|
other
|
The other matrix. | ||
factor
|
The
interpolation
factor
(0 :
this,
1 :
other).
|
|||
returns
|
The resulting matrix. |
Multiplies
this
matrix
(left-side)
with
the
given
one
(right-side):
result
=
this
*
m
.
[Pure]
|
||||
public
method
|
Mul
(Mat4D m)
|
|||
type
|
Mat4D
|
|||
params
|
m
|
The matrix. | ||
returns
|
The resulting matrix. |
Multiplies
this
matrix
(left-side)
with
the
given
homogeneous
3D
vector
(right-side):
result
=
this
*
v
.
[Pure]
|
||||
public
method
|
Mul3
(Vec3D v,
float64 w)
|
|||
type
|
Vec3D
|
|||
params
|
v
|
The vector. | ||
w
|
The W-component to assume. | |||
returns
|
The
resulting
vector,
scaled
by
1/result.W . |
Multiplies
this
matrix
(left-side)
with
the
given
homogeneous
3D
vector
(right-side):
result
=
this
*
v
.
[Pure]
|
||||
public
method
|
Mul3
(float64 x,
float64 y,
float64 z,
float64 w)
|
|||
type
|
Vec3D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
z
|
Z-component of vector. | |||
w
|
The W-component to assume. | |||
returns
|
The
resulting
vector,
scaled
by
1/result.W . |
Multiplies
this
matrix
(left-side)
with
the
given
4D
vector
(right-side):
result
=
this
*
v
.
[Pure]
|
||||
public
method
|
Mul4
(Vec4D v)
|
|||
type
|
Vec4D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Multiplies
this
matrix
(left-side)
with
the
given
4D
vector
(right-side):
result
=
this
*
v
.
[Pure]
|
||||
public
method
|
Mul4
(float64 x,
float64 y,
float64 z,
float64 w)
|
|||
type
|
Vec4D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
z
|
Z-component of vector. | |||
w
|
W-component of vector. | |||
returns
|
The resulting vector. |
Computes a ray for a screen-pixel.
[Pure]
|
||||
public
method
|
PerspectiveRay
(Vec3D translation,
float64 pixelX,
float64 pixelY,
int32 screenWidth,
int32 screenHeight,
bool nearAtZero)
|
|||
type
|
Ray
|
|||
params
|
translation
|
The translation components, if they have been omitted in the view projection, otherwise Zero. | ||
pixelX
|
Pixel X-coordinate (see remarks). | |||
pixelY
|
Pixel Y-coordinate (see remarks). | |||
screenWidth
|
Screen width, in pixels. | |||
screenHeight
|
Screen height, in pixels. | |||
nearAtZero
|
When
true ,
the
near
clipping
plane
will
be
mapped
to
0
in
clip-space
(e.g.
Direct3D);
when
false
it
will
be
mapped
to
-1
(e.g.
OpenGL).
|
|||
returns
|
The ray |
Remarks:
This
matrix
must
be
the
inverse
of
a
combined
world-view-projection
matrix
(for
example,
PerspectiveFov).
The
pixel
coordinates
(0,0)
refer
to
the
top-left
corner
of
the
top-left
screen
pixel.
The
pixel
coordinates
(w,h)
refer
to
the
bottom-right
corner
of
the
bottom-right
screen
pixel
(where
w
and
h
are
the
screen
width
resp.
height).
If
you
want
to
cast
rays
for
pixel
centers,
you
have
to
add
an
offset
of
0.5
to
the
pixel
coordinates.
Copies matrix elements to the given array.
public
method
|
ToArray
([]
float64[] values,
int32 offset = 0,
int32 strideRow = 4,
int32 strideCol = 1)
|
||
params
|
values
|
[not-null]
|
The output array. |
offset
|
Offset
into
values
to
top-left
matrix
element.
Defaults
to
0 .
|
||
strideRow
|
Array
index
distance
between
matrix
rows.
Defaults
to
4 .
|
||
strideCol
|
Array
index
distance
between
matrix
columns.
Defaults
to
1 .
|
Remarks:
The method uses the following indexing scheme to write values to values:
values[offset + (row - 1) * strideRow + (col - 1) * strideCol := matrix[row, col];where
row
and
col
depict
the
matrix
row
and
column
number
(starting
at
1
).
The serialization helper object for values of Mat4D.
public
static
readonly
field
|
Serializer
|
||
type
|
ITypeSerializer<Mat4D>
|