Each of these functions calls the corresponding version of
Transform::rotate(), and returns its return value, namely, aTransformrepresenting the rotation only.In the first version, taking three
realarguments, thePointis rotated x degrees around the x-axis, y degrees around the y-axis, and z degrees around the z-axis in that order.Point p0(1, 0, 2); p0.rotate(90); p0.show("p0:") -| p0: (1, 2, 0) Point p1(-1, 1, 1); p1.rotate(-90, 90, 90); p1.show("pt1:"); -| p1: (1, -1, -1)
![]()
Fig. 81.
Please note that rotations are not commutative operations. Nor are they commutative with other transformations. So, if you want to rotate a
Pointabout the x, y and z-axes in that order, you can do so with a single invocation ofrotate(), as in the previous example. However, if you want to rotate aPointfirst about the y-axis and then about the x-axis, you must invokerotate()twice.Point pt0(1, 1, 1); pt0.rotate(0, 45); pt0.rotate(45); pt0.show("pt0:"); -| pt0: (0, 1.70711, 0.292893)In the version taking two
Pointarguments p0 and p1, and arealargument angle, thePointis rotatedangledegrees around the axis determined by p0 and p1, 180 degrees by default.Point P(2, 0, 0); Point A; Point B(2, 2, 2); P.rotate(A, B, 180);
![]()
Fig. 82.
Calls
transform.scale(x,y,z)and returns its return value, namely, aTransformrepresenting the scaling operation only.Scaling causes the x-coordinate of the
Pointto be multiplied by x, the y-coordinate of thePointto be multiplied by y, and the z-coordinate of thePointto be multiplied by z.Point p0(1, 0, 3); p0.scale(4); p0.show("p0:"); -| p0: (4, 0, 3) Point p1(-2, -1, -2); p1.scale(-2, -3, -4); p1.show("p1:"); -| p1: (4, 3, 8)
![]()
Fig. 83.
Calls
transform.shear()with the same arguments and returns its return value, namely, aTransformrepresenting the shearing operation only.Shearing modifies each coordinate of a
Pointproportionately to the values of the other two coordinates. Let x_0, y_0, and z_0 stand for the coordinates of aPointP beforeP.shear(\alpha, \beta, \gamma, \delta, \epsilon, \zeta), and x_1, y_1, and z_1 for its coordinates afterwards.x_1 == x_0 + \alpha y + \beta z y_1 == y_0 + \gamma x + \delta z z_1 == z_0 + \epsilon x + \zeta y[next figure] demonstrates the effect of shearing the four
Pointsof a 3 * 3
Rectangle(i.e., a square) r in the x-y plane using only an xy argument, making it non-rectangular.Point P0; Point P1(3); Point P2(3, 3); Point P3(0, 3); Rectangle r(p0, p1, p2, p3); r.draw(); r.shear(1.5); r.draw(black, "evenly");
![]()
Fig. 84.
Each of these functions calls the corresponding version of
Transform::shift()ontransform, and returns its return value, namely, aTransformrepresenting the shifting operation only.The
Pointis shifted x units in the direction of the positive x-axis, y units in the direction of the positive y-axis, and z units in the direction of the positive z-axis.p0(1, 2, 3); p0.shift(2, 3, 5); p0.show("p0:"); -| p0: (3, 5, 8)
Each of these functions calls the corresponding version of
Transform::shift_times()ontransformand returns its return value, namely the new value oftransform.
shift_times()makes it possible to increase the magnitude of a shift applied to aPoint, while maintaining its direction. Please note thatshift_times()will only have an effect if it's called after a call toshift()and beforetransformis reset. This is performed byreset_transform(), which is called inapply_transform(), and can also be called directly. See Transform Reference; Resetting, and Point Reference; Applying Transformations.Point P; P.drawdot(); P.shift(1, 1, 1); P.drawdot(); P.shift_times(2, 2, 2); P.drawdot(); P.shift_times(2, 2, 2); P.drawdot(); P.shift_times(2, 2, 2); P.drawdot();
![]()
Fig. 85.