3 ident, matmul, matmulr, determinant, adjoint, invertmat, xformpoint, xformpointd, xformplane, pushmat, popmat, rot, qrot, scale, move, xform, ixform, persp, look, viewport \- Geometric transformations
16 void matmul(Matrix a, Matrix b)
19 void matmulr(Matrix a, Matrix b)
22 double determinant(Matrix m)
25 void adjoint(Matrix m, Matrix madj)
28 double invertmat(Matrix m, Matrix inv)
31 Point3 xformpoint(Point3 p, Space *to, Space *from)
34 Point3 xformpointd(Point3 p, Space *to, Space *from)
37 Point3 xformplane(Point3 p, Space *to, Space *from)
40 Space *pushmat(Space *t)
43 Space *popmat(Space *t)
46 void rot(Space *t, double theta, int axis)
49 void qrot(Space *t, Quaternion q)
52 void scale(Space *t, double x, double y, double z)
55 void move(Space *t, double x, double y, double z)
58 void xform(Space *t, Matrix m)
61 void ixform(Space *t, Matrix m, Matrix inv)
64 int persp(Space *t, double fov, double n, double f)
67 void look(Space *t, Point3 eye, Point3 look, Point3 up)
70 void viewport(Space *t, Rectangle r, double aspect)
72 These routines manipulate 3-space affine and projective transformations,
73 represented as 4\(mu4 matrices, thus:
77 typedef double Matrix[4][4];
81 stores an identity matrix in its argument.
93 returns the determinant of matrix
96 stores the adjoint (matrix of cofactors) of
101 stores the inverse of matrix
110 be singular (determinant zero),
116 The rest of the routines described here
123 is a point in three-space, represented by its
124 homogeneous coordinates:
127 typedef struct Point3 Point3;
133 The homogeneous coordinates
138 represent the Euclidean point
144 and a ``point at infinity'' if
149 is just a data structure describing a coordinate system:
152 typedef struct Space Space;
160 It contains a pair of transformation matrices and a pointer
163 parent. The matrices transform points to and from the ``root
164 coordinate system,'' which is represented by a null
171 Its argument is a pointer to the parent space. Its result
172 is a newly allocated copy of the parent, but with its
174 pointer pointing at the parent.
178 that is its argument, returning a pointer to the stack.
179 Nominally, these two functions define a stack of transformations,
182 can be called multiple times
185 multiple times, creating a transformation tree.
190 both transform points from the
194 to the space pointed to by
196 Either pointer may be null, indicating the root coordinate system.
197 The difference between the two functions is that
213 the Euclidean coordinates of the point.
216 transforms planes or normal vectors. A plane is specified by the
222 of its implicit equation
224 Since this representation is dual to the homogeneous representation of points,
239 The remaining functions transform the coordinate system represented
244 argument must be non-null \(em you can't modify the root
249 (in radians) about the given
257 transforms by a rotation about an arbitrary axis, specified by
262 scales the coordinate system by the given scale factors in the directions of the three axes.
264 translates by the given displacement in the three axial directions.
267 transforms the coordinate system by the given
269 If the matrix's inverse is known
274 will save the work of recomputing it.
277 does a perspective transformation.
278 The transformation maps the frustum with apex at the origin,
279 central axis down the positive
287 into the double-unit cube.
297 does a view-pointing transformation. The
299 point is moved to the origin.
304 points is aligned with the y axis,
305 and the plane containing the
310 points is rotated into the
315 maps the unit-cube window into the given screen viewport.
316 The viewport rectangle
320 at the top left-hand corner, and
322 just outside the lower right-hand corner.
327 of the viewport's pixels (not of the whole viewport).
328 The whole window is transformed to fit centered inside the viewport with equal
329 slop on either top and bottom or left and right, depending on the viewport's
331 The window is viewed down the
340 increasing to the right and
342 increasing down. The window's
344 coordinates are mapped, unchanged, into the viewport's
348 .B /usr/local/plan9/src/libgeometry/matrix.c