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 | \ /
The serialization helper object for values of Mat4D.
public
static
readonly
field
|
Serializer
|
||
type
|
ITypeSerializer<Mat4D>
|
The identity matrix.
public
static
readonly
field
|
Identity
|
||
type
|
Mat4D
|
The zero matrix.
public
static
readonly
field
|
Zero
|
||
type
|
Mat4D
|
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. |
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. |
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
(see
MV'
above). |
||
offset
|
Output
of
transformed
offset
vector
(see
O
above). |
Remarks:
The typical vertex coordinate 3D transformation pipeline can be describes as follows:
v* := P * MV * vwhere
v
is
a
vertex
point
in
model-space,
MV
is
the
combined
model-view
matrix,
P
is
the
projection
matrix
and
v*
is
the
transformed
vertex
point
in
clip-space.
Most
often,
the
combined
model-view-projection
matrix
P
*
MV
is
computed
by
the
CPU
and
sent
to
a
GPU
shader
for
further
processing.
Significant
precision
issues
will
arise
if
the
following
conditions
hold
true:
MV
contains
translational
components
of
great
magnitude.
v* := P * MV' * (v - O)where
O
is
an
offset
vector
that
represents
the
removed
translational
components
of
MV
transformed
back
into
model-space
and
MV'
is
the
reduced
model-view
matrix
(i.e.
without
translational
components).
public
method
|
Equals
(Mat4D other)
|
||
type
|
bool
|
||
params
|
other
|
public
method
|
EqualsAlmost
(Mat4D other)
|
||
type
|
bool
|
||
params
|
other
|
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. |
[Pure]
|
||||
public
static
method
|
LookAt
(Vec3D origin,
Vec3D target,
Vec3D up,
bool rightHanded)
|
|||
type
|
Mat4D
|
|||
params
|
origin
|
|||
target
|
||||
up
|
||||
rightHanded
|
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. |
public
static
method
|
Orthographic
(float64 left,
float64 right,
float64 top,
float64 bottom,
float64 zNear,
float64 zFar,
bool nearAtZero,
bool rightHanded)
|
||
type
|
Mat4D
|
||
params
|
left
|
||
right
|
|||
top
|
|||
bottom
|
|||
zNear
|
|||
zFar
|
|||
nearAtZero
|
|||
rightHanded
|
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. |
Computes a ray for a screen-pixel.
[Pure]
|
||||
public
method
|
PerspectiveRay
(Vec3D translation,
float64 pixelX,
float64 pixelY,
int32 screenWidth,
int32 screenHeight,
bool nearAtZero,
out Vec3D origin,
out Vec3D direction)
|
|||
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).
|
|||
origin
|
Output for origin of ray. | |||
direction
|
Output for unit-length ray direction vector. |
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.
[Pure]
|
||||
public
static
method
|
Rotate
(Vec3D axis,
float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
axis
|
|||
angle
|
[Pure]
|
||||
public
static
method
|
Rotate
(float64 x,
float64 y,
float64 z,
float64 angle)
|
|||
type
|
Mat4D
|
|||
params
|
x
|
|||
y
|
||||
z
|
||||
angle
|
Returns a rotation matrix (counter-clockwise around X-axis).
[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).
[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).
[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. |
Copies matrix elements to the given array.
[Pure]
|
||||
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
).
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
.