1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<!-- $Id: mat4.html 220 2001-01-16 21:21:46Z garland $ -->
<html>
<head>
<title>libgfx: Matrix Math</title>
<link rel=stylesheet href="cdoc.css" type="text/css">
<meta name="Author" content="Michael Garland">
</head>
<body>
<h2>Matrix Math</h2>
<h3>class Mat4</h3>
<p>This class implements a 4x4 real-valued matrix.
Individual elements are represented with <code>double</code> precision
floating point numbers. To use the <tt>Mat4</tt> class you must include the
header
<pre>
#include <gfx/mat4.h>
</pre>
<h4>Constructor Methods</h4>
<p>The <tt>Mat4</tt> class defines the following set of constructors:
<pre>
<i>// Initialize all elements to 0</i>
Mat4();
<i>// Initialize rows with given vectors</i>
Mat4(const Vec4& r0,const Vec4& r1,const Vec4& r2,const Vec4& r3);
<i>// Copy values from A</i>
Mat4(const Mat4& A);
</pre>
<h4>Transformation Functions</h4>
<p>Because 4x4 matrices are commonly used to represent linear homogeneous
transformations in computer graphics, the matrix package provides several
functions to construct transformation matrices. The operation of these
functions is based directly on the definition of the corresponding
transformations as used in OpenGL. The resulting matrices should be
equivalent to those produced by OpenGL, to the extent allowed by limited
floating point accuracy.
<pre>
<i>// Construct translation, scaling, and rotation matrices.</i>
Mat4 translation_matrix(const Vec3& delta);
Mat4 scaling_matrix(const Vec3& scale);
Mat4 rotation_matrix_deg(double theta, const Vec3& axis);
Mat4 rotation_matrix_rad(double theta, const Vec3& axis);
<i>// Construct a perspective projection matrix.
// Direct analog of gluPerspective()</i>
Mat4 perspective_matrix(double fovy, double aspect,
double zmin=0.0, double zmax=0.0);
<i>// Construct a viewing transformation.
// Direct analog of gluLookAt()</i>
Mat4 lookat_matrix(const Vec3& from, const Vec3& at, const Vec3& up);
<i>// Construct a viewport mapping.
// Direct analog of glViewport().</i>
Mat4 viewport_matrix(double w, double h);
</pre>
Note that the <tt>rotation_matrix()</tt> function comes in two forms, once
which expects an angle in <em>radians</em> and one which expects an angle in
<em>degrees</em>. The type of angle expected is made explicit in the function
name (i.e., <tt>_rad</tt> and <tt>_deg</tt> suffixes) in an attempt to avoid
confusion.
</body>
</html>
|