Represents a 4x4 Matrix with double-precision components. More...
Public Member Functions | |
| Matrix4d (Vector4d row0, Vector4d row1, Vector4d row2, Vector4d row3) | |
| Constructs a new instance. | |
| Matrix4d (double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) | |
| Constructs a new instance. | |
| void | Invert () |
| Converts this instance into its inverse. | |
| void | Transpose () |
| Converts this instance into its transpose. | |
| override string | ToString () |
| Returns a System.String that represents the current Matrix44. | |
| override int | GetHashCode () |
| Returns the hashcode for this instance. | |
| override bool | Equals (object obj) |
| Indicates whether this instance and a specified object are equal. | |
| bool | Equals (Matrix4d other) |
| Indicates whether the current matrix is equal to another matrix. | |
Static Public Member Functions | |
| static void | CreateFromAxisAngle (Vector3d axis, double angle, out Matrix4d result) |
| Build a rotation matrix from the specified axis/angle rotation. | |
| static Matrix4d | CreateFromAxisAngle (Vector3d axis, double angle) |
| Build a rotation matrix from the specified axis/angle rotation. | |
| static void | CreateRotationX (double angle, out Matrix4d result) |
| Builds a rotation matrix for a rotation around the x-axis. | |
| static Matrix4d | CreateRotationX (double angle) |
| Builds a rotation matrix for a rotation around the x-axis. | |
| static void | CreateRotationY (double angle, out Matrix4d result) |
| Builds a rotation matrix for a rotation around the y-axis. | |
| static Matrix4d | CreateRotationY (double angle) |
| Builds a rotation matrix for a rotation around the y-axis. | |
| static void | CreateRotationZ (double angle, out Matrix4d result) |
| Builds a rotation matrix for a rotation around the z-axis. | |
| static Matrix4d | CreateRotationZ (double angle) |
| Builds a rotation matrix for a rotation around the z-axis. | |
| static void | CreateTranslation (double x, double y, double z, out Matrix4d result) |
| Creates a translation matrix. | |
| static void | CreateTranslation (ref Vector3d vector, out Matrix4d result) |
| Creates a translation matrix. | |
| static Matrix4d | CreateTranslation (double x, double y, double z) |
| Creates a translation matrix. | |
| static Matrix4d | CreateTranslation (Vector3d vector) |
| Creates a translation matrix. | |
| static void | CreateOrthographic (double width, double height, double zNear, double zFar, out Matrix4d result) |
| Creates an orthographic projection matrix. | |
| static Matrix4d | CreateOrthographic (double width, double height, double zNear, double zFar) |
| Creates an orthographic projection matrix. | |
| static void | CreateOrthographicOffCenter (double left, double right, double bottom, double top, double zNear, double zFar, out Matrix4d result) |
| Creates an orthographic projection matrix. | |
| static Matrix4d | CreateOrthographicOffCenter (double left, double right, double bottom, double top, double zNear, double zFar) |
| Creates an orthographic projection matrix. | |
| static void | CreatePerspectiveFieldOfView (double fovy, double aspect, double zNear, double zFar, out Matrix4d result) |
| Creates a perspective projection matrix. | |
| static Matrix4d | CreatePerspectiveFieldOfView (double fovy, double aspect, double zNear, double zFar) |
| Creates a perspective projection matrix. | |
| static void | CreatePerspectiveOffCenter (double left, double right, double bottom, double top, double zNear, double zFar, out Matrix4d result) |
| Creates an perspective projection matrix. | |
| static Matrix4d | CreatePerspectiveOffCenter (double left, double right, double bottom, double top, double zNear, double zFar) |
| Creates an perspective projection matrix. | |
| static Matrix4d | Translation (Vector3d trans) |
| Build a translation matrix with the given translation. | |
| static Matrix4d | Translation (double x, double y, double z) |
| Build a translation matrix with the given translation. | |
| static Matrix4d | Scale (double scale) |
| Build a scaling matrix. | |
| static Matrix4d | Scale (Vector3d scale) |
| Build a scaling matrix. | |
| static Matrix4d | Scale (double x, double y, double z) |
| Build a scaling matrix. | |
| static Matrix4d | RotateX (double angle) |
| Build a rotation matrix that rotates about the x-axis. | |
| static Matrix4d | RotateY (double angle) |
| Build a rotation matrix that rotates about the y-axis. | |
| static Matrix4d | RotateZ (double angle) |
| Build a rotation matrix that rotates about the z-axis. | |
| static Matrix4d | Rotate (Vector3d axis, double angle) |
| Build a rotation matrix to rotate about the given axis. | |
| static Matrix4d | Rotate (Quaterniond q) |
| Build a rotation matrix from a quaternion. | |
| static Matrix4d | LookAt (Vector3d eye, Vector3d target, Vector3d up) |
| Build a world space to camera space matrix. | |
| static Matrix4d | LookAt (double eyeX, double eyeY, double eyeZ, double targetX, double targetY, double targetZ, double upX, double upY, double upZ) |
| Build a world space to camera space matrix. | |
| static Matrix4d | Frustum (double left, double right, double bottom, double top, double near, double far) |
| Build a projection matrix. | |
| static Matrix4d | Perspective (double fovy, double aspect, double near, double far) |
| Build a projection matrix. | |
| static Matrix4d | Mult (Matrix4d left, Matrix4d right) |
| Multiplies two instances. | |
| static void | Mult (ref Matrix4d left, ref Matrix4d right, out Matrix4d result) |
| Multiplies two instances. | |
| static Matrix4d | Invert (Matrix4d mat) |
| Calculate the inverse of the given matrix. | |
| static Matrix4d | Transpose (Matrix4d mat) |
| Calculate the transpose of the given matrix. | |
| static void | Transpose (ref Matrix4d mat, out Matrix4d result) |
| Calculate the transpose of the given matrix. | |
| static Matrix4d | operator* (Matrix4d left, Matrix4d right) |
| Matrix multiplication. | |
| static bool | operator== (Matrix4d left, Matrix4d right) |
| Compares two instances for equality. | |
| static bool | operator!= (Matrix4d left, Matrix4d right) |
| Compares two instances for inequality. | |
Public Attributes | |
| Vector4d | Row0 |
| Top row of the matrix. | |
| Vector4d | Row1 |
| 2nd row of the matrix | |
| Vector4d | Row2 |
| 3rd row of the matrix | |
| Vector4d | Row3 |
| Bottom row of the matrix. | |
Static Public Attributes | |
| static Matrix4d | Identity = new Matrix4d(Vector4d .UnitX, Vector4d .UnitY, Vector4d .UnitZ, Vector4d .UnitW) |
| The identity matrix. | |
Properties | |
| double | Determinant [get] |
| The determinant of this matrix. | |
| Vector4d | Column0 [get] |
| The first column of this matrix. | |
| Vector4d | Column1 [get] |
| The second column of this matrix. | |
| Vector4d | Column2 [get] |
| The third column of this matrix. | |
| Vector4d | Column3 [get] |
| The fourth column of this matrix. | |
| double | M11 [get, set] |
| Gets or sets the value at row 1, column 1 of this instance. | |
| double | M12 [get, set] |
| Gets or sets the value at row 1, column 2 of this instance. | |
| double | M13 [get, set] |
| Gets or sets the value at row 1, column 3 of this instance. | |
| double | M14 [get, set] |
| Gets or sets the value at row 1, column 4 of this instance. | |
| double | M21 [get, set] |
| Gets or sets the value at row 2, column 1 of this instance. | |
| double | M22 [get, set] |
| Gets or sets the value at row 2, column 2 of this instance. | |
| double | M23 [get, set] |
| Gets or sets the value at row 2, column 3 of this instance. | |
| double | M24 [get, set] |
| Gets or sets the value at row 2, column 4 of this instance. | |
| double | M31 [get, set] |
| Gets or sets the value at row 3, column 1 of this instance. | |
| double | M32 [get, set] |
| Gets or sets the value at row 3, column 2 of this instance. | |
| double | M33 [get, set] |
| Gets or sets the value at row 3, column 3 of this instance. | |
| double | M34 [get, set] |
| Gets or sets the value at row 3, column 4 of this instance. | |
| double | M41 [get, set] |
| Gets or sets the value at row 4, column 1 of this instance. | |
| double | M42 [get, set] |
| Gets or sets the value at row 4, column 2 of this instance. | |
| double | M43 [get, set] |
| Gets or sets the value at row 4, column 3 of this instance. | |
| double | M44 [get, set] |
| Gets or sets the value at row 4, column 4 of this instance. | |
Represents a 4x4 Matrix with double-precision components.
Definition at line 35 of file Matrix4d.cs.
| OpenTK.Matrix4d.Matrix4d | ( | double | m00, | |
| double | m01, | |||
| double | m02, | |||
| double | m03, | |||
| double | m10, | |||
| double | m11, | |||
| double | m12, | |||
| double | m13, | |||
| double | m20, | |||
| double | m21, | |||
| double | m22, | |||
| double | m23, | |||
| double | m30, | |||
| double | m31, | |||
| double | m32, | |||
| double | m33 | |||
| ) |
Constructs a new instance.
| m00 | First item of the first row. | |
| m01 | Second item of the first row. | |
| m02 | Third item of the first row. | |
| m03 | Fourth item of the first row. | |
| m10 | First item of the second row. | |
| m11 | Second item of the second row. | |
| m12 | Third item of the second row. | |
| m13 | Fourth item of the second row. | |
| m20 | First item of the third row. | |
| m21 | Second item of the third row. | |
| m22 | Third item of the third row. | |
| m23 | First item of the third row. | |
| m30 | Fourth item of the fourth row. | |
| m31 | Second item of the fourth row. | |
| m32 | Third item of the fourth row. | |
| m33 | Fourth item of the fourth row. |
Definition at line 99 of file Matrix4d.cs.
Build a rotation matrix from the specified axis/angle rotation.
| axis | The axis to rotate about. | |
| angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). |
Definition at line 306 of file Matrix4d.cs.
00307 { 00308 Matrix4d result; 00309 CreateFromAxisAngle(axis, angle, out result); 00310 return result; 00311 }
| static void OpenTK.Matrix4d.CreateFromAxisAngle | ( | Vector3d | axis, | |
| double | angle, | |||
| out Matrix4d | result | |||
| ) | [static] |
Build a rotation matrix from the specified axis/angle rotation.
| axis | The axis to rotate about. | |
| angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). | |
| result | A matrix instance. |
Definition at line 286 of file Matrix4d.cs.
00287 { 00288 double cos = System.Math.Cos(-angle); 00289 double sin = System.Math.Sin(-angle); 00290 double t = 1.0 - cos; 00291 00292 axis.Normalize(); 00293 00294 result = new Matrix4d(t * axis.X * axis.X + cos, t * axis.X * axis.Y - sin * axis.Z, t * axis.X * axis.Z + sin * axis.Y, 0.0, 00295 t * axis.X * axis.Y + sin * axis.Z, t * axis.Y * axis.Y + cos, t * axis.Y * axis.Z - sin * axis.X, 0.0, 00296 t * axis.X * axis.Z - sin * axis.Y, t * axis.Y * axis.Z + sin * axis.X, t * axis.Z * axis.Z + cos, 0.0, 00297 0, 0, 0, 1); 00298 }
| static Matrix4d OpenTK.Matrix4d.CreateOrthographic | ( | double | width, | |
| double | height, | |||
| double | zNear, | |||
| double | zFar | |||
| ) | [static] |
Creates an orthographic projection matrix.
| width | The width of the projection volume. | |
| height | The height of the projection volume. | |
| zNear | The near edge of the projection volume. | |
| zFar | The far edge of the projection volume. |
<rereturns>The resulting Matrix4d instance.</rereturns>
Definition at line 480 of file Matrix4d.cs.
00481 { 00482 Matrix4d result; 00483 CreateOrthographicOffCenter(-width / 2, width / 2, -height / 2, height / 2, zNear, zFar, out result); 00484 return result; 00485 }
| static void OpenTK.Matrix4d.CreateOrthographic | ( | double | width, | |
| double | height, | |||
| double | zNear, | |||
| double | zFar, | |||
| out Matrix4d | result | |||
| ) | [static] |
Creates an orthographic projection matrix.
| width | The width of the projection volume. | |
| height | The height of the projection volume. | |
| zNear | The near edge of the projection volume. | |
| zFar | The far edge of the projection volume. | |
| result | The resulting Matrix4d instance. |
Definition at line 467 of file Matrix4d.cs.
00468 { 00469 CreateOrthographicOffCenter(-width / 2, width / 2, -height / 2, height / 2, zNear, zFar, out result); 00470 }
| static Matrix4d OpenTK.Matrix4d.CreateOrthographicOffCenter | ( | double | left, | |
| double | right, | |||
| double | bottom, | |||
| double | top, | |||
| double | zNear, | |||
| double | zFar | |||
| ) | [static] |
Creates an orthographic projection matrix.
| left | The left edge of the projection volume. | |
| right | The right edge of the projection volume. | |
| bottom | The bottom edge of the projection volume. | |
| top | The top edge of the projection volume. | |
| zNear | The near edge of the projection volume. | |
| zFar | The far edge of the projection volume. |
Definition at line 529 of file Matrix4d.cs.
00530 { 00531 Matrix4d result; 00532 CreateOrthographicOffCenter(left, right, bottom, top, zNear, zFar, out result); 00533 return result; 00534 }
| static void OpenTK.Matrix4d.CreateOrthographicOffCenter | ( | double | left, | |
| double | right, | |||
| double | bottom, | |||
| double | top, | |||
| double | zNear, | |||
| double | zFar, | |||
| out Matrix4d | result | |||
| ) | [static] |
Creates an orthographic projection matrix.
| left | The left edge of the projection volume. | |
| right | The right edge of the projection volume. | |
| bottom | The bottom edge of the projection volume. | |
| top | The top edge of the projection volume. | |
| zNear | The near edge of the projection volume. | |
| zFar | The far edge of the projection volume. | |
| result | The resulting Matrix4d instance. |
Definition at line 501 of file Matrix4d.cs.
00502 { 00503 result = new Matrix4d(); 00504 00505 double invRL = 1 / (right - left); 00506 double invTB = 1 / (top - bottom); 00507 double invFN = 1 / (zFar - zNear); 00508 00509 result.M11 = 2 * invRL; 00510 result.M22 = 2 * invTB; 00511 result.M33 = -2 * invFN; 00512 00513 result.M41 = -(right + left) * invRL; 00514 result.M42 = -(top + bottom) * invTB; 00515 result.M43 = -(zFar + zNear) * invFN; 00516 result.M44 = 1; 00517 }
| static Matrix4d OpenTK.Matrix4d.CreatePerspectiveFieldOfView | ( | double | fovy, | |
| double | aspect, | |||
| double | zNear, | |||
| double | zFar | |||
| ) | [static] |
Creates a perspective projection matrix.
| fovy | Angle of the field of view in the y direction (in radians) | |
| aspect | Aspect ratio of the view (width / height) | |
| zNear | Distance to the near clip plane | |
| zFar | Distance to the far clip plane |
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
Definition at line 597 of file Matrix4d.cs.
00598 { 00599 Matrix4d result; 00600 CreatePerspectiveFieldOfView(fovy, aspect, zNear, zFar, out result); 00601 return result; 00602 }
| static void OpenTK.Matrix4d.CreatePerspectiveFieldOfView | ( | double | fovy, | |
| double | aspect, | |||
| double | zNear, | |||
| double | zFar, | |||
| out Matrix4d | result | |||
| ) | [static] |
Creates a perspective projection matrix.
| fovy | Angle of the field of view in the y direction (in radians) | |
| aspect | Aspect ratio of the view (width / height) | |
| zNear | Distance to the near clip plane | |
| zFar | Distance to the far clip plane | |
| result | A projection matrix that transforms camera space to raster space |
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
Definition at line 558 of file Matrix4d.cs.
00559 { 00560 if (fovy <= 0 || fovy > Math.PI) 00561 throw new ArgumentOutOfRangeException("fovy"); 00562 if (aspect <= 0) 00563 throw new ArgumentOutOfRangeException("aspect"); 00564 if (zNear <= 0) 00565 throw new ArgumentOutOfRangeException("zNear"); 00566 if (zFar <= 0) 00567 throw new ArgumentOutOfRangeException("zFar"); 00568 if (zNear >= zFar) 00569 throw new ArgumentOutOfRangeException("zNear"); 00570 00571 double yMax = zNear * System.Math.Tan(0.5 * fovy); 00572 double yMin = -yMax; 00573 double xMin = yMin * aspect; 00574 double xMax = yMax * aspect; 00575 00576 CreatePerspectiveOffCenter(xMin, xMax, yMin, yMax, zNear, zFar, out result); 00577 }
| static Matrix4d OpenTK.Matrix4d.CreatePerspectiveOffCenter | ( | double | left, | |
| double | right, | |||
| double | bottom, | |||
| double | top, | |||
| double | zNear, | |||
| double | zFar | |||
| ) | [static] |
Creates an perspective projection matrix.
| left | Left edge of the view frustum | |
| right | Right edge of the view frustum | |
| bottom | Bottom edge of the view frustum | |
| top | Top edge of the view frustum | |
| zNear | Distance to the near clip plane | |
| zFar | Distance to the far clip plane |
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
Definition at line 666 of file Matrix4d.cs.
00667 { 00668 Matrix4d result; 00669 CreatePerspectiveOffCenter(left, right, bottom, top, zNear, zFar, out result); 00670 return result; 00671 }
| static void OpenTK.Matrix4d.CreatePerspectiveOffCenter | ( | double | left, | |
| double | right, | |||
| double | bottom, | |||
| double | top, | |||
| double | zNear, | |||
| double | zFar, | |||
| out Matrix4d | result | |||
| ) | [static] |
Creates an perspective projection matrix.
| left | Left edge of the view frustum | |
| right | Right edge of the view frustum | |
| bottom | Bottom edge of the view frustum | |
| top | Top edge of the view frustum | |
| zNear | Distance to the near clip plane | |
| zFar | Distance to the far clip plane | |
| result | A projection matrix that transforms camera space to raster space |
| System.ArgumentOutOfRangeException | Thrown under the following conditions:
|
Definition at line 626 of file Matrix4d.cs.
00627 { 00628 if (zNear <= 0) 00629 throw new ArgumentOutOfRangeException("zNear"); 00630 if (zFar <= 0) 00631 throw new ArgumentOutOfRangeException("zFar"); 00632 if (zNear >= zFar) 00633 throw new ArgumentOutOfRangeException("zNear"); 00634 00635 double x = (2.0 * zNear) / (right - left); 00636 double y = (2.0 * zNear) / (top - bottom); 00637 double a = (right + left) / (right - left); 00638 double b = (top + bottom) / (top - bottom); 00639 double c = -(zFar + zNear) / (zFar - zNear); 00640 double d = -(2.0 * zFar * zNear) / (zFar - zNear); 00641 00642 result = new Matrix4d(x, 0, 0, 0, 00643 0, y, 0, 0, 00644 a, b, c, -1, 00645 0, 0, d, 0); 00646 }
| static Matrix4d OpenTK.Matrix4d.CreateRotationX | ( | double | angle | ) | [static] |
Builds a rotation matrix for a rotation around the x-axis.
| angle | The counter-clockwise angle in radians. |
Definition at line 338 of file Matrix4d.cs.
00339 { 00340 Matrix4d result; 00341 CreateRotationX(angle, out result); 00342 return result; 00343 }
| static void OpenTK.Matrix4d.CreateRotationX | ( | double | angle, | |
| out Matrix4d | result | |||
| ) | [static] |
Builds a rotation matrix for a rotation around the x-axis.
| angle | The counter-clockwise angle in radians. | |
| result | The resulting Matrix4 instance. |
Definition at line 322 of file Matrix4d.cs.
| static Matrix4d OpenTK.Matrix4d.CreateRotationY | ( | double | angle | ) | [static] |
Builds a rotation matrix for a rotation around the y-axis.
| angle | The counter-clockwise angle in radians. |
Definition at line 366 of file Matrix4d.cs.
00367 { 00368 Matrix4d result; 00369 CreateRotationY(angle, out result); 00370 return result; 00371 }
| static void OpenTK.Matrix4d.CreateRotationY | ( | double | angle, | |
| out Matrix4d | result | |||
| ) | [static] |
Builds a rotation matrix for a rotation around the y-axis.
| angle | The counter-clockwise angle in radians. | |
| result | The resulting Matrix4 instance. |
Definition at line 350 of file Matrix4d.cs.
| static Matrix4d OpenTK.Matrix4d.CreateRotationZ | ( | double | angle | ) | [static] |
Builds a rotation matrix for a rotation around the z-axis.
| angle | The counter-clockwise angle in radians. |
Definition at line 394 of file Matrix4d.cs.
00395 { 00396 Matrix4d result; 00397 CreateRotationZ(angle, out result); 00398 return result; 00399 }
| static void OpenTK.Matrix4d.CreateRotationZ | ( | double | angle, | |
| out Matrix4d | result | |||
| ) | [static] |
Builds a rotation matrix for a rotation around the z-axis.
| angle | The counter-clockwise angle in radians. | |
| result | The resulting Matrix4 instance. |
Definition at line 378 of file Matrix4d.cs.
Creates a translation matrix.
| vector | The translation vector. |
Definition at line 448 of file Matrix4d.cs.
00449 { 00450 Matrix4d result; 00451 CreateTranslation(vector.X, vector.Y, vector.Z, out result); 00452 return result; 00453 }
| static Matrix4d OpenTK.Matrix4d.CreateTranslation | ( | double | x, | |
| double | y, | |||
| double | z | |||
| ) | [static] |
Creates a translation matrix.
| x | X translation. | |
| y | Y translation. | |
| z | Z translation. |
Definition at line 436 of file Matrix4d.cs.
00437 { 00438 Matrix4d result; 00439 CreateTranslation(x, y, z, out result); 00440 return result; 00441 }
Creates a translation matrix.
| vector | The translation vector. | |
| result | The resulting Matrix4d instance. |
Definition at line 423 of file Matrix4d.cs.
00424 { 00425 result = Identity; 00426 result.Row3 = new Vector4d(vector.X, vector.Y, vector.Z, 1); 00427 }
| static void OpenTK.Matrix4d.CreateTranslation | ( | double | x, | |
| double | y, | |||
| double | z, | |||
| out Matrix4d | result | |||
| ) | [static] |
Creates a translation matrix.
| x | X translation. | |
| y | Y translation. | |
| z | Z translation. | |
| result | The resulting Matrix4d instance. |
Definition at line 412 of file Matrix4d.cs.
00413 { 00414 result = Identity; 00415 result.Row3 = new Vector4d(x, y, z, 1); 00416 }
| bool OpenTK.Matrix4d.Equals | ( | Matrix4d | other | ) |
Indicates whether the current matrix is equal to another matrix.
| other | An matrix to compare with this matrix. |
Definition at line 1206 of file Matrix4d.cs.
| override bool OpenTK.Matrix4d.Equals | ( | object | obj | ) |
Indicates whether this instance and a specified object are equal.
| obj | The object to compare to. |
Definition at line 1187 of file Matrix4d.cs.
| static Matrix4d OpenTK.Matrix4d.Frustum | ( | double | left, | |
| double | right, | |||
| double | bottom, | |||
| double | top, | |||
| double | near, | |||
| double | far | |||
| ) | [static] |
Build a projection matrix.
| left | Left edge of the view frustum | |
| right | Right edge of the view frustum | |
| bottom | Bottom edge of the view frustum | |
| top | Top edge of the view frustum | |
| near | Distance to the near clip plane | |
| far | Distance to the far clip plane |
Definition at line 896 of file Matrix4d.cs.
00897 { 00898 double invRL = 1.0 / (right - left); 00899 double invTB = 1.0 / (top - bottom); 00900 double invFN = 1.0 / (far - near); 00901 return new Matrix4d(new Vector4d (2.0 * near * invRL, 0.0, 0.0, 0.0), 00902 new Vector4d (0.0, 2.0 * near * invTB, 0.0, 0.0), 00903 new Vector4d ((right + left) * invRL, (top + bottom) * invTB, -(far + near) * invFN, -1.0), 00904 new Vector4d (0.0, 0.0, -2.0 * far * near * invFN, 0.0)); 00905 }
| override int OpenTK.Matrix4d.GetHashCode | ( | ) |
Calculate the inverse of the given matrix.
| mat | The matrix to invert |
| InvalidOperationException | Thrown if the Matrix4d is singular. |
Definition at line 979 of file Matrix4d.cs.
00980 { 00981 int[] colIdx = { 0, 0, 0, 0 }; 00982 int[] rowIdx = { 0, 0, 0, 0 }; 00983 int[] pivotIdx = { -1, -1, -1, -1 }; 00984 00985 // convert the matrix to an array for easy looping 00986 double[,] inverse = {{mat.Row0.X, mat.Row0.Y, mat.Row0.Z, mat.Row0.W}, 00987 {mat.Row1.X, mat.Row1.Y, mat.Row1.Z, mat.Row1.W}, 00988 {mat.Row2.X, mat.Row2.Y, mat.Row2.Z, mat.Row2.W}, 00989 {mat.Row3.X, mat.Row3.Y, mat.Row3.Z, mat.Row3.W} }; 00990 int icol = 0; 00991 int irow = 0; 00992 for (int i = 0; i < 4; i++) 00993 { 00994 // Find the largest pivot value 00995 double maxPivot = 0.0; 00996 for (int j = 0; j < 4; j++) 00997 { 00998 if (pivotIdx[j] != 0) 00999 { 01000 for (int k = 0; k < 4; ++k) 01001 { 01002 if (pivotIdx[k] == -1) 01003 { 01004 double absVal = System.Math.Abs(inverse[j, k]); 01005 if (absVal > maxPivot) 01006 { 01007 maxPivot = absVal; 01008 irow = j; 01009 icol = k; 01010 } 01011 } 01012 else if (pivotIdx[k] > 0) 01013 { 01014 return mat; 01015 } 01016 } 01017 } 01018 } 01019 01020 ++(pivotIdx[icol]); 01021 01022 // Swap rows over so pivot is on diagonal 01023 if (irow != icol) 01024 { 01025 for (int k = 0; k < 4; ++k) 01026 { 01027 double f = inverse[irow, k]; 01028 inverse[irow, k] = inverse[icol, k]; 01029 inverse[icol, k] = f; 01030 } 01031 } 01032 01033 rowIdx[i] = irow; 01034 colIdx[i] = icol; 01035 01036 double pivot = inverse[icol, icol]; 01037 // check for singular matrix 01038 if (pivot == 0.0) 01039 { 01040 throw new InvalidOperationException("Matrix is singular and cannot be inverted."); 01041 //return mat; 01042 } 01043 01044 // Scale row so it has a unit diagonal 01045 double oneOverPivot = 1.0 / pivot; 01046 inverse[icol, icol] = 1.0; 01047 for (int k = 0; k < 4; ++k) 01048 inverse[icol, k] *= oneOverPivot; 01049 01050 // Do elimination of non-diagonal elements 01051 for (int j = 0; j < 4; ++j) 01052 { 01053 // check this isn't on the diagonal 01054 if (icol != j) 01055 { 01056 double f = inverse[j, icol]; 01057 inverse[j, icol] = 0.0; 01058 for (int k = 0; k < 4; ++k) 01059 inverse[j, k] -= inverse[icol, k] * f; 01060 } 01061 } 01062 } 01063 01064 for (int j = 3; j >= 0; --j) 01065 { 01066 int ir = rowIdx[j]; 01067 int ic = colIdx[j]; 01068 for (int k = 0; k < 4; ++k) 01069 { 01070 double f = inverse[k, ir]; 01071 inverse[k, ir] = inverse[k, ic]; 01072 inverse[k, ic] = f; 01073 } 01074 } 01075 01076 mat.Row0 = new Vector4d (inverse[0, 0], inverse[0, 1], inverse[0, 2], inverse[0, 3]); 01077 mat.Row1 = new Vector4d (inverse[1, 0], inverse[1, 1], inverse[1, 2], inverse[1, 3]); 01078 mat.Row2 = new Vector4d (inverse[2, 0], inverse[2, 1], inverse[2, 2], inverse[2, 3]); 01079 mat.Row3 = new Vector4d (inverse[3, 0], inverse[3, 1], inverse[3, 2], inverse[3, 3]); 01080 return mat; 01081 }
| void OpenTK.Matrix4d.Invert | ( | ) |
Converts this instance into its inverse.
Definition at line 255 of file Matrix4d.cs.
00256 { 00257 this = Matrix4d.Invert(this); 00258 }
| static Matrix4d OpenTK.Matrix4d.LookAt | ( | double | eyeX, | |
| double | eyeY, | |||
| double | eyeZ, | |||
| double | targetX, | |||
| double | targetY, | |||
| double | targetZ, | |||
| double | upX, | |||
| double | upY, | |||
| double | upZ | |||
| ) | [static] |
Build a world space to camera space matrix.
| eyeX | Eye (camera) position in world space | |
| eyeY | Eye (camera) position in world space | |
| eyeZ | Eye (camera) position in world space | |
| targetX | Target position in world space | |
| targetY | Target position in world space | |
| targetZ | Target position in world space | |
| upX | Up vector in world space (should not be parallel to the camera direction, that is target - eye) | |
| upY | Up vector in world space (should not be parallel to the camera direction, that is target - eye) | |
| upZ | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
Definition at line 881 of file Matrix4d.cs.
00882 { 00883 return LookAt(new Vector3d(eyeX, eyeY, eyeZ), new Vector3d(targetX, targetY, targetZ), new Vector3d(upX, upY, upZ)); 00884 }
Build a world space to camera space matrix.
| eye | Eye (camera) position in world space | |
| target | Target position in world space | |
| up | Up vector in world space (should not be parallel to the camera direction, that is target - eye) |
Definition at line 852 of file Matrix4d.cs.
00853 { 00854 Vector3d z = Vector3d.Normalize(eye - target); 00855 Vector3d x = Vector3d.Normalize(Vector3d.Cross(up, z)); 00856 Vector3d y = Vector3d.Normalize(Vector3d.Cross(z, x)); 00857 00858 Matrix4d rot = new Matrix4d(new Vector4d (x.X, y.X, z.X, 0.0), 00859 new Vector4d (x.Y, y.Y, z.Y, 0.0), 00860 new Vector4d (x.Z, y.Z, z.Z, 0.0), 00861 Vector4d .UnitW); 00862 00863 Matrix4d trans = Matrix4d.CreateTranslation(-eye); 00864 00865 return trans * rot; 00866 }
| static void OpenTK.Matrix4d.Mult | ( | ref Matrix4d | left, | |
| ref Matrix4d | right, | |||
| out Matrix4d | result | |||
| ) | [static] |
Multiplies two instances.
| left | The left operand of the multiplication. | |
| right | The right operand of the multiplication. | |
| result | A new instance that is the result of the multiplication |
Definition at line 948 of file Matrix4d.cs.
00949 { 00950 result = new Matrix4d(); 00951 result.M11 = left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31 + left.M14 * right.M41; 00952 result.M12 = left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32 + left.M14 * right.M42; 00953 result.M13 = left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33 + left.M14 * right.M43; 00954 result.M14 = left.M11 * right.M14 + left.M12 * right.M24 + left.M13 * right.M34 + left.M14 * right.M44; 00955 result.M21 = left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31 + left.M24 * right.M41; 00956 result.M22 = left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32 + left.M24 * right.M42; 00957 result.M23 = left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33 + left.M24 * right.M43; 00958 result.M24 = left.M21 * right.M14 + left.M22 * right.M24 + left.M23 * right.M34 + left.M24 * right.M44; 00959 result.M31 = left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31 + left.M34 * right.M41; 00960 result.M32 = left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32 + left.M34 * right.M42; 00961 result.M33 = left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33 + left.M34 * right.M43; 00962 result.M34 = left.M31 * right.M14 + left.M32 * right.M24 + left.M33 * right.M34 + left.M34 * right.M44; 00963 result.M41 = left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31 + left.M44 * right.M41; 00964 result.M42 = left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32 + left.M44 * right.M42; 00965 result.M43 = left.M41 * right.M13 + left.M42 * right.M23 + left.M43 * right.M33 + left.M44 * right.M43; 00966 result.M44 = left.M41 * right.M14 + left.M42 * right.M24 + left.M43 * right.M34 + left.M44 * right.M44; 00967 }
Multiplies two instances.
| left | The left operand of the multiplication. | |
| right | The right operand of the multiplication. |
Definition at line 935 of file Matrix4d.cs.
Compares two instances for inequality.
| left | The first instance. | |
| right | The second instance. |
Definition at line 1145 of file Matrix4d.cs.
Matrix multiplication.
| left | left-hand operand | |
| right | right-hand operand |
Definition at line 1123 of file Matrix4d.cs.
01124 { 01125 return Matrix4d.Mult(left, right); 01126 }
Compares two instances for equality.
| left | The first instance. | |
| right | The second instance. |
Definition at line 1134 of file Matrix4d.cs.
| static Matrix4d OpenTK.Matrix4d.Perspective | ( | double | fovy, | |
| double | aspect, | |||
| double | near, | |||
| double | far | |||
| ) | [static] |
Build a projection matrix.
| fovy | Angle of the field of view in the y direction (in radians) | |
| aspect | Aspect ratio of the view (width / height) | |
| near | Distance to the near clip plane | |
| far | Distance to the far clip plane |
Definition at line 915 of file Matrix4d.cs.
00916 { 00917 double yMax = near * System.Math.Tan(0.5f * fovy); 00918 double yMin = -yMax; 00919 double xMin = yMin * aspect; 00920 double xMax = yMax * aspect; 00921 00922 return Frustum(xMin, xMax, yMin, yMax, near, far); 00923 }
| static Matrix4d OpenTK.Matrix4d.Rotate | ( | Quaterniond | q | ) | [static] |
Build a rotation matrix from a quaternion.
| q | the quaternion |
Definition at line 833 of file Matrix4d.cs.
00834 { 00835 Vector3d axis; 00836 double angle; 00837 q.ToAxisAngle(out axis, out angle); 00838 return Rotate(axis, angle); 00839 }
Build a rotation matrix to rotate about the given axis.
| axis | the axis to rotate about | |
| angle | angle in radians to rotate counter-clockwise (looking in the direction of the given axis) |
Definition at line 812 of file Matrix4d.cs.
00813 { 00814 double cos = System.Math.Cos(-angle); 00815 double sin = System.Math.Sin(-angle); 00816 double t = 1.0 - cos; 00817 00818 axis.Normalize(); 00819 00820 Matrix4d result; 00821 result.Row0 = new Vector4d (t * axis.X * axis.X + cos, t * axis.X * axis.Y - sin * axis.Z, t * axis.X * axis.Z + sin * axis.Y, 0.0); 00822 result.Row1 = new Vector4d (t * axis.X * axis.Y + sin * axis.Z, t * axis.Y * axis.Y + cos, t * axis.Y * axis.Z - sin * axis.X, 0.0); 00823 result.Row2 = new Vector4d (t * axis.X * axis.Z - sin * axis.Y, t * axis.Y * axis.Z + sin * axis.X, t * axis.Z * axis.Z + cos, 0.0); 00824 result.Row3 = Vector4d .UnitW; 00825 return result; 00826 }
| static Matrix4d OpenTK.Matrix4d.RotateX | ( | double | angle | ) | [static] |
Build a rotation matrix that rotates about the x-axis.
| angle | angle in radians to rotate counter-clockwise around the x-axis |
Definition at line 757 of file Matrix4d.cs.
00758 { 00759 double cos = System.Math.Cos(angle); 00760 double sin = System.Math.Sin(angle); 00761 00762 Matrix4d result; 00763 result.Row0 = Vector4d .UnitX; 00764 result.Row1 = new Vector4d (0.0, cos, sin, 0.0); 00765 result.Row2 = new Vector4d (0.0, -sin, cos, 0.0); 00766 result.Row3 = Vector4d .UnitW; 00767 return result; 00768 }
| static Matrix4d OpenTK.Matrix4d.RotateY | ( | double | angle | ) | [static] |
Build a rotation matrix that rotates about the y-axis.
| angle | angle in radians to rotate counter-clockwise around the y-axis |
Definition at line 775 of file Matrix4d.cs.
00776 { 00777 double cos = System.Math.Cos(angle); 00778 double sin = System.Math.Sin(angle); 00779 00780 Matrix4d result; 00781 result.Row0 = new Vector4d (cos, 0.0, -sin, 0.0); 00782 result.Row1 = Vector4d .UnitY; 00783 result.Row2 = new Vector4d (sin, 0.0, cos, 0.0); 00784 result.Row3 = Vector4d .UnitW; 00785 return result; 00786 }
| static Matrix4d OpenTK.Matrix4d.RotateZ | ( | double | angle | ) | [static] |
Build a rotation matrix that rotates about the z-axis.
| angle | angle in radians to rotate counter-clockwise around the z-axis |
Definition at line 793 of file Matrix4d.cs.
00794 { 00795 double cos = System.Math.Cos(angle); 00796 double sin = System.Math.Sin(angle); 00797 00798 Matrix4d result; 00799 result.Row0 = new Vector4d (cos, sin, 0.0, 0.0); 00800 result.Row1 = new Vector4d (-sin, cos, 0.0, 0.0); 00801 result.Row2 = Vector4d .UnitZ; 00802 result.Row3 = Vector4d .UnitW; 00803 return result; 00804 }
| static Matrix4d OpenTK.Matrix4d.Scale | ( | double | x, | |
| double | y, | |||
| double | z | |||
| ) | [static] |
Build a scaling matrix.
| x | Scale factor for x-axis | |
| y | Scale factor for y-axis | |
| z | Scale factor for z-axis |
Definition at line 738 of file Matrix4d.cs.
00739 { 00740 Matrix4d result; 00741 result.Row0 = Vector4d .UnitX * x; 00742 result.Row1 = Vector4d .UnitY * y; 00743 result.Row2 = Vector4d .UnitZ * z; 00744 result.Row3 = Vector4d .UnitW; 00745 return result; 00746 }
Build a scaling matrix.
| scale | Scale factors for x,y and z axes |
Definition at line 726 of file Matrix4d.cs.
00727 { 00728 return Scale(scale.X, scale.Y, scale.Z); 00729 }
| static Matrix4d OpenTK.Matrix4d.Scale | ( | double | scale | ) | [static] |
Build a scaling matrix.
| scale | Single scale factor for x,y and z axes |
Definition at line 716 of file Matrix4d.cs.
00717 { 00718 return Scale(scale, scale, scale); 00719 }
| override string OpenTK.Matrix4d.ToString | ( | ) |
| static Matrix4d OpenTK.Matrix4d.Translation | ( | double | x, | |
| double | y, | |||
| double | z | |||
| ) | [static] |
Build a translation matrix with the given translation.
| x | X translation | |
| y | Y translation | |
| z | Z translation |
Definition at line 698 of file Matrix4d.cs.
Build a translation matrix with the given translation.
| trans | The vector to translate along |
Definition at line 685 of file Matrix4d.cs.
00686 { 00687 return Translation(trans.X, trans.Y, trans.Z); 00688 }
Calculate the transpose of the given matrix.
| mat | The matrix to transpose | |
| result | The result of the calculation |
Definition at line 1103 of file Matrix4d.cs.
Calculate the transpose of the given matrix.
| mat | The matrix to transpose |
Definition at line 1092 of file Matrix4d.cs.
01093 { 01094 return new Matrix4d(mat.Column0, mat.Column1, mat.Column2, mat.Column3); 01095 }
| void OpenTK.Matrix4d.Transpose | ( | ) |
Converts this instance into its transpose.
Definition at line 267 of file Matrix4d.cs.
00268 { 00269 this = Matrix4d.Transpose(this); 00270 }
Matrix4d OpenTK.Matrix4d.Identity = new Matrix4d(Vector4d .UnitX, Vector4d .UnitY, Vector4d .UnitZ, Vector4d .UnitW) [static] |
The identity matrix.
Definition at line 59 of file Matrix4d.cs.
Top row of the matrix.
Definition at line 42 of file Matrix4d.cs.
2nd row of the matrix
Definition at line 46 of file Matrix4d.cs.
3rd row of the matrix
Definition at line 50 of file Matrix4d.cs.
Bottom row of the matrix.
Definition at line 54 of file Matrix4d.cs.
Vector4d OpenTK.Matrix4d.Column0 [get] |
The first column of this matrix.
Definition at line 138 of file Matrix4d.cs.
Vector4d OpenTK.Matrix4d.Column1 [get] |
The second column of this matrix.
Definition at line 146 of file Matrix4d.cs.
Vector4d OpenTK.Matrix4d.Column2 [get] |
The third column of this matrix.
Definition at line 154 of file Matrix4d.cs.
Vector4d OpenTK.Matrix4d.Column3 [get] |
The fourth column of this matrix.
Definition at line 162 of file Matrix4d.cs.
double OpenTK.Matrix4d.Determinant [get] |
The determinant of this matrix.
Definition at line 121 of file Matrix4d.cs.
double OpenTK.Matrix4d.M11 [get, set] |
Gets or sets the value at row 1, column 1 of this instance.
Definition at line 169 of file Matrix4d.cs.
double OpenTK.Matrix4d.M12 [get, set] |
Gets or sets the value at row 1, column 2 of this instance.
Definition at line 174 of file Matrix4d.cs.
double OpenTK.Matrix4d.M13 [get, set] |
Gets or sets the value at row 1, column 3 of this instance.
Definition at line 179 of file Matrix4d.cs.
double OpenTK.Matrix4d.M14 [get, set] |
Gets or sets the value at row 1, column 4 of this instance.
Definition at line 184 of file Matrix4d.cs.
double OpenTK.Matrix4d.M21 [get, set] |
Gets or sets the value at row 2, column 1 of this instance.
Definition at line 189 of file Matrix4d.cs.
double OpenTK.Matrix4d.M22 [get, set] |
Gets or sets the value at row 2, column 2 of this instance.
Definition at line 194 of file Matrix4d.cs.
double OpenTK.Matrix4d.M23 [get, set] |
Gets or sets the value at row 2, column 3 of this instance.
Definition at line 199 of file Matrix4d.cs.
double OpenTK.Matrix4d.M24 [get, set] |
Gets or sets the value at row 2, column 4 of this instance.
Definition at line 204 of file Matrix4d.cs.
double OpenTK.Matrix4d.M31 [get, set] |
Gets or sets the value at row 3, column 1 of this instance.
Definition at line 209 of file Matrix4d.cs.
double OpenTK.Matrix4d.M32 [get, set] |
Gets or sets the value at row 3, column 2 of this instance.
Definition at line 214 of file Matrix4d.cs.
double OpenTK.Matrix4d.M33 [get, set] |
Gets or sets the value at row 3, column 3 of this instance.
Definition at line 219 of file Matrix4d.cs.
double OpenTK.Matrix4d.M34 [get, set] |
Gets or sets the value at row 3, column 4 of this instance.
Definition at line 224 of file Matrix4d.cs.
double OpenTK.Matrix4d.M41 [get, set] |
Gets or sets the value at row 4, column 1 of this instance.
Definition at line 229 of file Matrix4d.cs.
double OpenTK.Matrix4d.M42 [get, set] |
Gets or sets the value at row 4, column 2 of this instance.
Definition at line 234 of file Matrix4d.cs.
double OpenTK.Matrix4d.M43 [get, set] |
Gets or sets the value at row 4, column 3 of this instance.
Definition at line 239 of file Matrix4d.cs.
double OpenTK.Matrix4d.M44 [get, set] |
Gets or sets the value at row 4, column 4 of this instance.
Definition at line 244 of file Matrix4d.cs.
1.6.1