圓柱的截痕
Author: 藍邦偉  老師

分別拉動r與h決定圓柱的半徑與高，拉動D,E兩點決定截面

顯示單位向量

h = 5 (slider from 1 to 10, step 1)
O = (10.047787653122517, 2.280942081047972)
r = 4 (slider from 1 to 10, step 1)
B: (x((4.0 * Corner[3.0] + 16.0 * Corner[4.0]) / 20.0), y((Corner[1.0] + 9.0 * Corner[4.0]) / 10.0))
A: (x((Corner[3.0] + 39.0 * Corner[4.0]) / 40.0), y((Corner[1.0] + 9.0 * Corner[4.0]) / 10.0))
D_1: (3.0 * B + A) / 4.0
n: x = x(D_1)
a = Segment(A, B)
E = Point(a)
C_1: (3.0 * A + B) / 4.0
E' = Rotate(Translate[E, Vector[C_1, D_1]], 90.0*°, D_1)
c = Circle(C_1, E)
c' = Translate(c, Vector[Vector[C_1, D_1]])
G_1 = Point(c')
c'' = Rotate(c', 270.0*°, C_1)
F = Point(c'')
A' = Rotate(A, 270.0*°, C_1)
B' = Rotate(B, 270.0*°, C_1)
a' = Segment(A', B')
D'_1 = Rotate(D_1, 270.0*°, C_1)
b = Segment(D'_1, F)
E'' = Rotate(E', 270.0*°, C_1)
α = Angle(E'', D'_1, F)
d_1 = Segment(D_1, G_1)
β = Angle(G_1, D_1, E')
K: C_1 + (0.0, b * cos(β))
K' = Translate(K, Vector[Vector[C_1, O]])
w = Vector(O, K')
J_2: O - h * w
v_1 = Vector(J_2, O)
e_1: y = y(J_2)
O_1 = Intersect(n, e_1)
I: C_1 + (b * cos(α), b * sin(α) * sin(β))
J: C_1 + (b * cos(α + 90.0°), b * sin(α + 90.0°) * sin(β))
f = Segment(C_1, I)
g = Segment(C_1, J)
I' = Translate(I, Vector[Vector[C_1, O]])
J' = Translate(J, Vector[Vector[C_1, O]])
L: r + 2.0
h_1 = Segment(D'_1, E'')
i = Segment(D_1, E')
軌跡1 = Locus(I, F)
L_{axis}: L
u = Vector(O, I')
v = Vector(O, J')
k = false
m_1 = CurveCartesian(x(O + r * cos(t) * u + r * sin(t) * v + h * w), y(O + r * cos(t) * u + r * sin(t) * v + h * w), t, 0.0, 6.28)
o = CurveCartesian(x(O + r * cos(t) * u + r * sin(t) * v - h * w), y(O + r * cos(t) * u + r * sin(t) * v - h * w), t, 0.0, 6.28)
J_1: O + h * w
H, M = Intersect(c, a)
u_0 = Vector(C_1, H)
U_1: J_1 + r * u_0
p = Segment(J_1, J_2)
N = Mirror(U_1, J_1)
P_1 = Mirror(U_1, O)
N' = Mirror(N, O)
P = Point(o)
n_1 = Segment(P, J_2)
t = Segment(P_1, N')
P_2: P + 2.0 * h * w
a_1 = Segment(P_2, J_1)
b_1 = Segment(J_1, U_1)
c_1 = Segment(P_2, P)
B_0: O + r * cos(0.0°) * u + r * sin(0.0°) * v - h * w
B_1: O + r * cos(60.0°) * u + r * sin(60.0°) * v - h * w
B_2: O + r * cos(160.0°) * u + r * sin(160.0°) * v - h * w
B_3: O + r * cos(260.0°) * u + r * sin(260.0°) * v - h * w
B_4: O + r * cos(300.0°) * u + r * sin(300.0°) * v - h * w
B_5: O + r * cos(0.0°) * u + r * sin(0.0°) * v + h * w
B_6: O + r * cos(60.0°) * u + r * sin(60.0°) * v + h * w
B_7: O + r * cos(160.0°) * u + r * sin(160.0°) * v + h * w
B_8: O + r * cos(260.0°) * u + r * sin(260.0°) * v + h * w
B_9: O + r * cos(300.0°) * u + r * sin(300.0°) * v + h * w
q = Conic(B_5, B_6, B_7, B_8, B_9)
l, m = Tangent(O, q)
C = Intersect(q, l)
D = Intersect(q, m)
G = Intersect(l, m)
d = Conic(B_0, B_1, B_2, B_3, B_4)
Q, S = Intersect(d, l)
R, T = Intersect(d, m)
j = Segment(D, R)
s = Segment(Q, C)
l_a = Vector(J_2, R)
O_A = Translate(O_1, l_a)
O_b: O_1 + (0.0, 0.7)
f_1 = Segment(O_1, O_A)
g_1 = Segment(O_b, O_1)
k_1: (x - x(O_1))^(2.0) / f_1^(2.0) + (y - y(O_1))^(2.0) / g_1^(2.0) = 1.0
O_H = Translate(O_1, v_1)
i_1 = Segment(O_H, O_1)
j_1 = Segment(O_H, O_A)
O_C = Point(i_1)
O_D = Point(j_1)
l_1 = Segment(O_C, O_D)
p_1 = Circle(O_C, 0.5 * f_1)
O_E = Point(p_1)
z = Vector(O_E, O_C)
O_{E'} = Translate(O_C, z)
u_1 = Vector(O_C, O_D)
O_F = Translate(O_E, u_1)
O_{F'} = Translate(O_{E'}, u_1)
多邊形1, o_e, o_{e'}, o_{f'}, o_f = Polygon(O_E, O_{E'}, O_{F'}, O_F)
w_1 = Vector(J_2, O_1)
e = Translate(d, w_1)
e' = Dilate(e, 0.5, O_1)