Node:Alignment with an Axis for Transforms, Next:Resetting Transforms, Previous:Affine Transformations for Transforms, Up:Transform Reference
| Transform align_with_axis (Point p0, Point p1, [char axis = 'z']) | Function |
Returns the Transform that would align the line through p0
and p1 with the major axis denoted by the axis argument.
The default is the z-axis. This function is used in the functions that
find intersections.
Point P0(1, 1, 1);
Point P1(2, 3, 4);
P0.draw(P1);
P0.dotlabel("$P_0$");
P1.dotlabel("$P_1$");
Transform t;
t.align_with_axis(P0, P1, 'z');
P0 *= P1 *= t;
t.show("t:");
-| t:
0.949 -0.169 0.267 0
0 0.845 0.535 0
-0.316 -0.507 0.802 0
-0.632 -0.169 -1.6 1
P0.show("P0:");
-| P0: (0, 0, 0)
P1.show("P1:");
-| P1: (0, 0, 3.74)
The following example shows how default_focus.set(2, 3, -10, 2, 3, 10, 10);
Circle c(origin, 3, 75, 25, 6);
c.shift(2, 3);
c.draw();
Point n = c.get_normal();
n.shift(c.get_center());
Transform t;
t.align_with_axis(c.get_center(), n, 'y');
t.show("t:");
-| t:
0.686 0.379 -0.621 0
0.543 0.3 0.784 0
0.483 -0.875 0 0
-3 -1.66 -1.11 1
n *= c *= t;
c.draw();
c.show("c:");
-| c:
fill_draw_value == 0
(1.31, 0, -0.728) .. (1.49, 0, -0.171) ..
(1.44, 0, 0.413) .. (1.17, 0, 0.933) ..
(0.728, 0, 1.31) .. (0.171, 0, 1.49) ..
(-0.413, 0, 1.44) .. (-0.933, 0, 1.17) ..
(-1.31, 0, 0.728) .. (-1.49, 0, 0.171) ..
(-1.44, 0, -0.413) .. (-1.17, 0, -0.933) ..
(-0.728, 0, -1.31) .. (-0.171, 0, -1.49) ..
(0.413, 0, -1.44) .. (0.933, 0, -1.17) .. cycle;
n.show("n:");
-| n: (0, 1, 0)
|