Node: Affine Transformations for Paths, Next: , Previous: Modifying Paths, Up: Path Reference



Affine Transformations

Transform rotate (const real x, [const real y = 0, [const real z = 0]]) Virtual function
Creates a Transform t locally and calls t.rotate(x, y, z). t is then applied to all of the Points on points. The return value is t.

Transform scale (real x, [real y = 1, [real z = 1]]) Function
Creates a Transform t locally and calls t.scale(x, y, z). t is then applied to all of the Points on points. The return value is t.

The Points on the Path are scaled according to the arguments:

          Point pt[8];
          pt[0] = (-1, -1);
          for (int i = 1; i < 8; ++i)
            {
              pt[i] = pt[0];
              pt[i].rotate(0, 0, i * 45);
            }
          Path p("--", true, &pt[0], &pt[1], &pt[2], &pt[3],
                 &pt[4], &pt[5], &pt[6],
                 &pt[7], 0);
          p.draw();
          p.scale(2, 2);
          p.draw();
          


[Figure 115. Not displayed.]

Fig. 115.

Transform shear (real xy, [real xz = 0, [real yx = 0, [real yz = 0, [real zx = 0, [real zy = 0]]]]]) Function
Creates a Transform t locally and calls t.shear(xy, xz, yx, yz, zx, zy). t is then applied to all of the Points on points. The return value is t.
          Point p0;
          Point p1(1);
          Point p2(1, 1);
          Point p3(0, 1);
          Path q("--", true, &p0, &p1, &p2, &p3, 0);
          q.rotate(0, 45);
          q.shift(1);
          q.filldraw(black, light_gray);
          q.shear(1.5, 2, 2.5, 3, 3.5, 5);
          q.filldraw(black, light_gray);
          


[Figure 116. Not displayed.]

Fig. 116.

Transform shift (real x, [real y = 0, [real z = 0]]) Function
Creates a Transform t locally and calls t.shift(x, y, z). t is then applied to all of the Points on points. The return value is t.

Shifts each of the Points on the Path according to the arguments.

          default_focus.set(5, 10, -10, 0, 10, 10, 10);
          Point pt[6];
          pt[0].set(-2, -2);
          pt[1].set(0, -3);
          pt[2].set(2, -2);
          pt[3].set(2, 2);
          pt[4].set(0, 3);
          pt[5].set(-2, 2);
          Path p("--", true, &pt[0], &pt[1], &pt[2],
                 &pt[3], &pt[4], &pt[5], 0);
          p.draw();
          p.shift(3, 3, 3);
          p.draw();
          


[Figure 117. Not displayed.]

Fig. 117.

Transform shift (const Point& p) Function
Creates a Transform t locally and calls t.shift(p). t is then applied to all of the Points on points. The return value is t.

This version of shift() uses the x, y, and z-coordinates of the Point p to shift the Path.

          default_focus.set(5, 10, -10, 0, 10, 10, 10);
          Point pt[6];
          pt[0].set(-2, -2);
          pt[1].set(0, -3);
          pt[2].set(2, -2);
          pt[3].set(2, 2);
          pt[4].set(0, 3);
          pt[5].set(-2, 2);
          Path p("--", true, &pt[0], &pt[1], &pt[2],
                 &pt[3], &pt[4], &pt[5], 0);
          p.draw();
          Point s(1, 1, 1);
          p.shift(s);
          p.draw();
          


[Figure 118. Not displayed.]

Fig. 118.

void shift_times (real x, [real y = 1, [real z = 1]]) Virtual function
void shift_times (const Point& @var{p}) Virtual function
Each of these functions calls the corresponding version of Point::shift_times() on all of the Points on points. See Point Reference; Affine Transformations. The return value is void, because there is no guarantee that all of the Points on a Path will have identical transform members (although it's likely).

Please note that shift_times() will only have an effect on the Points on a Path if it's called after a call to shift() and before an operation is applied that causes Point::apply_transform() to be called.

Transform rotate (const Point& p0, const Point& p1, [const real angle = 180]) Virtual function
Creates a Transform t locally and calls t.rotate(p0, p1, angle). t is then applied to all of the Points on points. The return value is t.

Transform rotate (const Path& p, [const real angle = 180]) Function
If p.is_linear() returns true, this function creates a Transform t locally and calls t.rotate(p, angle). t is then applied to all of the Points on points. The return value is t. Otherwise, it issues an error message and returns INVALID_TRANSFORM.