Node:Affine Transformations for Transforms, Next:Alignment with an Axis for Transforms, Previous:Showing Transforms, Up:Transform Reference
The affine transformation functions use their arguments to create a new
Transform
t
(local to the function) representing the
appropriate transformation. Then, *this
is multiplied by t
and t
is returned.
Returning t
instead of *this
makes it possible to put the
affine transformation function at the end of a chain of invocations of
Transform::operator*=()
:
Transform t0, t1, t2, t3; ... t0 *= t1 *= t2 *= t3.scale(2, 3.5, 9);
t0
, t1
, and t2
are all multiplied by the
Transform
with
matrix
=
2 0 0 0
0 3.5 0 0
0 0 9 0
0 0 0 1
representing the scaling operation, not t3
, which may
represent a combination of transformations.
Transform scale (real x, [real y = 1, [real z = 1]]) | Function |
Creates a Transform t representing the scaling operation locally,
multiplies *this by t , and returns t .
A Transform representing scaling only, when applied to a
Point p , will cause its x-coordinate to be multiplied by
x, its y-coordinate to be multiplied by y, and its
z-coordinate to be multiplied by z.
=>
Transform t; t.scale(12.5, 20, 1.3); t.show("t:"); -| t: 12.5 0 0 0 0 20 0 0 0 0 1.3 0 0 0 0 1 |
Transform shear (real xy, [real xz = 0, [real yx = 0, [real yz = 0, [real zx = 0, [real zy = 0]]]]]) | Function |
Creates a Transform t representing the shearing operation locally,
multiplies *this by t , and returns t .
When applied to a Point p(x,y,z); Transform t; t.shear(a, b, c, d, e, f); p *= t; => p = ((x + ay + bz), (y + cx + dz), (z + ex + fy)) Transform t; t.shear(2, 3, 4, 5, 6, 7); t.show("t:"); -| t: 1 4 6 0 2 1 7 0 3 5 1 0 0 0 0 1 |
Transform shift (real x, [real y = 0, [real z = 0]]) | Function |
Transform shift (const Point& p) | Function |
These functions create a The version with the argument When a Point p(x,y,z); Transform t; t.shift(a, b, c); p *= t; => p = (x + a, y + b, z + c) |
Transform shift_times (real x, [real y = 1, [real z = 1]]) | Function |
Multiplies the corresponding elements of matrix by
the real arguments, i.e.,
matrix[3][0] is multiplied by x,
matrix[3][1] is multiplied by y, and
matrix[3][2] is multiplied by z. Returns *this .
Ordinary shifting is additive, so a special function is needed to
multiply the elements of If the Transform t; t.shift(1, 2, 3); =>
t.shift_times(2, 2, 2); =>
Rectangle r[4]; r[0].set(origin, 1, 1, 90); r[3] = r[2] = r[1] = r[0]; Transform t; t.shift(1.5, 1.5); r[0] *= t; r[0].draw(); t.shift_times(1.5, 1.5); r[1] *= t; r[1].draw(); t.shift_times(1.5, 1.5); r[2] *= t; r[2].draw(); t.shift_times(1.5, 1.5); r[3] *= t; r[3].draw();
Cuboid c(origin, 1, 1, 1); c.draw(); Transform t; t.rotate(30, 30, 30); t.shift(1, 0, 1); c *= t; c.draw(); t.shift_times(1.5, 0, 1.5); c *= t; c.draw(); t.shift_times(1.5, 0, 1.5); c *= t; c.draw(); t.shift_times(1.5, 0, 1.5); c *= t; c.draw(); t.shift_times(1.5, 0, 1.5); c *= t; c.draw();
|
Transform rotate (real x, [real y = 0, [real z = 0]]) | Function |
Rotation around the main axes.
Creates a Transform t representing the rotation,
multiplies *this by t , and returns t .
|
Transform rotate (Point p0, Point p1, [const real angle = 180]) | Function |
Rotation around an arbitrary axis. The Point arguments represent
the end points of the axis, and angle is the angle of rotation.
Since 180 degrees
rotation is needed so often, 180 is the default for
angle.
|
Transform rotate (const Path& p, [const real angle = 180]) | Function |
Rotation around an arbitrary axis. Path argument.
The Path p must be linear, i.e., p.is_linear() must
return true . See Path Reference; Querying.
|