Node:Aligning Paths with an Axis, Next:Applying Transformations to Paths, Previous:Affine Transformations for Paths, Up:Path Reference
| Transform align_with_axis ([const char axis = 'z']) | const function |
| Transform align_with_axis (bool assign, [const char axis = 'z']) | Function |
| Transform align_with_axis (const Point& p0, const Point& p1, const char axis) | Function |
These functions return the Transform which, if applied to the
Path, would align it with the major axis indicated by the
axis argument.
The first and second versions can only be called
for Point A(2, 3, 2);
Point B(-1, 1, 3);
Path p(A, B);
Transform t = p.align_with_axis(true, 'z');
t.show("t:");
-| t:
-0.316 0.507 -0.802 0
0 -0.845 -0.535 0
-0.949 -0.169 0.267 0
2.53 1.86 2.67 1
p *= t;
p.show("p:");
-| p:
(2.53, 1.86, 2.67) -- (-1.02, 1.23, 3.67);
Point C(1);
C *= t.inverse();
Path q;
q += "..";
q += C;
for (int i = 0; i < 15; ++i)
{
C.rotate(A, B, 360.0/16);
q += C;
}
q.set_cycle(true);
q.show("q:");
-| q:
(1.68, 3, 1.05) .. (1.9, 2.68, 1.06) ..
(2.13, 2.4, 1.21) .. (2.35, 2.22, 1.48) ..
(2.51, 2.15, 1.83) .. (2.59, 2.22, 2.21) ..
(2.58, 2.4, 2.55) .. (2.49, 2.68, 2.81) ..
(2.32, 3, 2.95) .. (2.1, 3.32, 2.94) ..
(1.87, 3.6, 2.79) .. (1.65, 3.78, 2.52) ..
(1.49, 3.85, 2.17) .. (1.41, 3.78, 1.79) ..
(1.42, 3.6, 1.45) .. (1.51, 3.32, 1.19) .. cycle;
q.align_with_axis(A, B, 'z');
q.show("q:");
-| q:
(1, 0, 0) .. (0.924, 0.383, 0) ..
(0.707, 0.707, 0) .. (0.383, 0.924, 0) ..
(0, 1, 0) .. (-0.383, 0.924, 0) ..
(-0.707, 0.707, 0) .. (-0.924, 0.383, 0) ..
(-1, 0, 0) .. (-0.924, -0.383, 0) ..
(-0.707, -0.707, 0) .. (-0.383, -0.924, 0) ..
(0, -1, 0) .. (0.383, -0.924, 0) ..
(0.707, -0.707, 0) .. (0.924, -0.383, 0) .. cycle;
|