薄片法與體積
Author: 藍邦偉　老師

單位向量

座標軸

x

y

z

$ 薄片法與體積 $

Start

q = -8.2 (slider from -r to r, step 0.3)
O = (10.492169455552697, 0.5838513901422543)
β = 1.3962634015954636 rad (slider from 0 to 6.283185307179586, step 0.1*°)
Z_{unit}: O + (0, sin(β))
w = Vector(O, Z_{unit})
α = 4.101523742186674 rad (slider from 0 to 6.283185307179586, step 0.01*°)
X_{unit}: O + (cos(α), sin(α) * cos(β))
u = Vector(O, X_{unit})
Y_{unit}: O + (-1 * sin(α), cos(α) * cos(β))
v = Vector(O, Y_{unit})
r = 8.2 (slider from 1 to 10, step 0.1)
A_{14}: O - r * u + (6 + 2 * sqrt(3)) * w
A_{13}: O + r * u + (6 + 2 * sqrt(3)) * w
M_1 = Midpoint(A_{13}, A_{14})
A_{12}: O + r * u - 2 * v + 6 * w
A_{11}: O - r * u - 2 * v + 6 * w
M_2 = Midpoint(A_{11}, A_{12})
A_{10}: O - r * u + 2 * v + 6 * w
A_9: O + r * u + 2 * v + 6 * w
M_3 = Midpoint(A_{10}, A_9)
L = 7 (slider from 1 to 10, step 1)
a = Vector(O - L * v, O + L * v)
b = Vector(O - L * w, O + L * w)
z_5 = Vector(O - L * u, O + L * u)
c = false
d = false
Q_2: 0.2 * Corner[2] + 0.8 * Corner[1]
Q_3: (x(Q_2), y(Corner[3]))
z = Segment(Q_2, Q_3)
poly1, z_1, z_2, z_3, z_4 = Polygon(Corner[1], Q_2, Q_3, Corner[4])
A_2: O - r * u + 2 * v
A_3: O - r * u - 2 * v
A_4: O + r * u - 2 * v
A_5: O + r * u + 2 * v + 4 * w
A_6: O - r * u + 2 * v + 4 * w
A_7: O - r * u - 2 * v + 4 * w
A_8: O + r * u - 2 * v + 4 * w
A_1: O + r * u + 2 * v
a_1, a_2 = SDLine(A_5, A_1, A_8, A_6)
a_3, a_4 = SDLine(A_8, A_4, A_7, A_5)
e, f = SDLine(A_6, A_2, A_5, A_7)
g, j = SDLine(A_7, A_3, A_6, A_8)
k, l = SDLine(A_{14}, A_{11}, A_{10}, A_{12})
m, n_2 = SDLine(A_8, A_7, A_5, A_4)
p, q_2 = SDLine(A_{14}, A_{10}, A_9, A_{11})
r_1, s_2 = SDLine(A_7, A_6, A_8, A_3)
t_2, b_1 = SDLine(A_6, A_5, A_7, A_2)
c_1, d_1 = SDLine(A_{13}, A_9, A_{12}, A_{10})
e_1, f_1 = SDLine(A_{13}, A_{12}, A_{11}, A_9)
g_1, h_1 = SDLine(A_5, A_8, A_6, A_1)
i_1, j_1 = SDLine(A_{14}, A_{13}, A_{11}, A_{10})
k_1, l_1 = SDLine(A_{10}, A_9, A_{14}, A_{11})
m_1, n_1 = SDLine(A_{11}, A_{10}, A_{12}, A_{14})
p_1, s_1 = SDLine(A_{12}, A_{11}, A_{13}, A_9)
t_1, b_2 = SDLine(A_9, A_{12}, A_{13}, A_{11})
c_2, d_2 = SDLine(A_3, A_4, A_2, A_7)
e_2, f_2 = SDLine(A_1, A_4, A_5, A_2)
g_2, h_2 = SDLine(A_2, A_1, A_6, A_3)
i_2, j_2 = SDLine(A_3, A_2, A_7, A_4)
c_a = CurveCartesian(x(O + 2 * cos(t) * v + 2 * sin(t) * w + 14 * w + r * u), y(O + 2 * cos(t) * v + r * u + 2 * sin(t) * w + 14 * w), t, 0, 6.28319)
c_b = CurveCartesian(x(O + 2 * cos(t) * v + 2 * sin(t) * w + 14 * w - r * u), y(O + 2 * cos(t) * v - r * u + 2 * sin(t) * w + 14 * w), t, 0, 6.28319)
h = Segment(O + 16 * w - r * u, O + 16 * w + r * u)
i = Segment(O + 12 * w - r * u, O + 12 * w + r * u)
q_1 = Segment(O + 14 * w - r * u + 2 * v, O + 14 * w + r * u + 2 * v)
k_2 = Segment(O + 14 * w - r * u - 2 * v, O + 14 * w + r * u - 2 * v)
tri_1, s, t, l_2 = Polygon(M_1 + q * u, M_2 + q * u, M_3 + q * u)
o = CurveCartesian(x(O + 2 * cos(t) * v + 2 * sin(t) * w + 14 * w + q * u), y(O + 2 * cos(t) * v + q * u + 2 * sin(t) * w + 14 * w), t, 0, 6.28319)
M_4 = Midpoint(A_5, A_6)
M_5 = Midpoint(A_8, A_7)
M_6 = Midpoint(A_1, A_2)
M_7 = Midpoint(A_3, A_4)
aquare, m_2, p_2, r_2, b_3 = Polygon(M_4 + q * u, M_5 + q * u, M_7 + q * u, M_6 + q * u)
poly2 = Poly_B3(A_{13}, A_{12}, A_9)
poly3 = Poly_B3(A_{14}, A_{10}, A_{11})
poly4 = Poly_B4(A_1, A_5, A_8, A_4)
poly5 = Poly_B4(A_7, A_6, A_2, A_3)
o_1 = CurveCartesian(x(O + 2 * cos(t) * v + 2 * sin(t) * w + 14 * w + r * u), y(O + 2 * cos(t) * v + r * u + 2 * sin(t) * w + 14 * w), t, 0, 6.28319)
u_1 = CurveCartesian(x(O + 2 * cos(t) * v + 2 * sin(t) * w + 14 * w - r * u), y(O + 2 * cos(t) * v - r * u + 2 * sin(t) * w + 14 * w), t, 0, 6.28319)
n = Segment(O + 14 * w - r * u - 2 * v, O + 14 * w + r * u - 2 * v)
c_3 = Segment(O + 14 * w - r * u + 2 * v, O + 14 * w + r * u + 2 * v)

Tool: SDLine
Input: A, B, C, D
Output: g, h

b: sgn(sin(Angle[D, B, A]))
a: sgn(sin(Angle[A, B, C]))
c: sgn(a + b + 0.5)
d: sqrt(c)
e: sqrt(-c)
E = Midpoint(A, B)
A' = Dilate(A, d, E)
B' = Dilate(B, d, E)
g = Segment(A', B')
A'_1 = Dilate(A, e, E)
B'_1 = Dilate(B, e, E)
h = Segment(A'_1, B'_1)

Tool: Poly_B3
Input: A, B, C
Output: poly1'

α = Angle(C, B, A)
d: sqrt(sgn(sin(α)))
A' = Dilate(A, d, A)
B' = Dilate(B, d, A)
C' = Dilate(C, d, A)
poly1', c', a', b' = Polygon(A', B', C')

Tool: Poly_B4
Input: A, B, C, D
Output: poly1'

α = Angle(C, B, A)
a: sqrt(sgn(sin(α)))
A' = Dilate(A, a, B)
B' = Dilate(B, a, B)
C' = Dilate(C, a, B)
D' = Dilate(D, a, B)
poly1', a', b', c', d' = Polygon(A', B', C', D')