@@ -270,16 +270,16 @@ function slice_mesh_at_plane(vertices, faces, point, normal; tol=1e-6)
270270end
271271
272272"""
273- march_edges(vertices, faces; step) -> (; le, te, point, tangent, arclen )
273+ march_edges(vertices, faces; step) -> (; le, te, point, tangent)
274274
275275March the leading edge outward from mid-span in both directions in steps of arc
276276length `step`. Each cut is a vertical spanwise plane (both the chordwise and vertical
277277components of the running LE tangent dropped from the normal) so a tip that curls
278278downward can't tilt the plane toward horizontal, where its min-chord "LE" pick would
279279jump across the wing. Marching stops when the leading edge stops advancing spanwise.
280280Cuts sample mesh *edges*, so the picks are robust to vertex density. Returns, ordered
281- along the span, the LE/TE points, each cut's plane origin and tangent, and the
282- cumulative LE arc length. Build the airfoil for a chosen station with `build_section`.
281+ along the span, the LE/TE points and each cut's plane origin and tangent. Build the
282+ airfoil for a chosen station with `build_section`.
283283"""
284284function march_edges (vertices, faces; step)
285285 ys = [v[2 ] for v in vertices]
@@ -318,7 +318,7 @@ function march_edges(vertices, faces; step)
318318 probe_mid = prev_le .+ mid .* tangent
319319 here = cut (probe_mid, tangent)
320320 # Reject a near-degenerate tip slice whose min-chord "LE" has jumped
321- # chordwise (an artifact that would skew the leading-edge arc length ).
321+ # chordwise (an artifact that would misplace the tip station ).
322322 valid = here != = nothing &&
323323 abs (here. le[1 ] - prev_le[1 ]) < step &&
324324 build_section (vertices, faces, here. le, here. te,
@@ -340,12 +340,8 @@ function march_edges(vertices, faces; step)
340340
341341 center = (; mid_cut. le, mid_cut. te, point= [0.0 , y_mid, 0.0 ], tangent= [0.0 , 1.0 , 0.0 ])
342342 rows = vcat (reverse (march (- 1.0 )), [center], march (1.0 ))
343- arclen = zeros (length (rows))
344- for i in 2 : length (rows)
345- arclen[i] = arclen[i- 1 ] + norm (rows[i]. le - rows[i- 1 ]. le)
346- end
347343 return (; le= [r. le for r in rows], te= [r. te for r in rows],
348- point= [r. point for r in rows], tangent= [r. tangent for r in rows], arclen )
344+ point= [r. point for r in rows], tangent= [r. tangent for r in rows])
349345end
350346
351347"""
@@ -429,12 +425,12 @@ end
429425
430426Extract `n_sections` airfoil cross-sections following a curved or swept span. The
431427leading edge is marched into `n_bins` stations (`march_edges`); the airfoil is
432- built (`build_section`) at the marched station nearest each equal
433- **leading-edge arc-length** target . Each section is
428+ built (`build_section`) at the marched station nearest each of `n_sections` targets
429+ spread evenly over the span ([`station_indices`](@ref)) . Each section is
434430`(; LE_point, TE_point, span_dir, contour3d, x_airfoil, y_airfoil)`.
435431
436- Stations closed to a point at the tips are skipped ([`station_indices`](@ref)), and
437- `wingtip_distance` insets the outermost sections a further arc length.
432+ Stations closed to a point at the tips are skipped, and `wingtip_distance` [m]
433+ insets the outermost sections a further spanwise length.
438434
439435The slicer assumes `x` = chordwise, `y` = spanwise, `z` = up. Pass a `3×3` rotation
440436matrix to reorient a mesh stored in another convention before slicing.
@@ -455,19 +451,24 @@ end
455451"""
456452 station_indices(march, n; wingtip_distance=0.0, min_chord_frac=0.01) -> Vector{Int}
457453
458- Indices of the [`march_edges`](@ref) stations nearest `n` targets spread over the
459- leading-edge arc length. Stations whose chord has closed to less than
460- `min_chord_frac` of the longest one are left out of that range first, so a wing
461- tapering to a point puts its outermost sections on the last stations that still
462- have an airfoil to slice rather than on the point itself. The remaining first and
463- last targets sit a further `wingtip_distance` (arc length) inboard.
454+ Indices of the [`march_edges`](@ref) stations nearest `n` targets spread evenly over
455+ the spanwise length of the quarter- chord line: its arc length with the chordwise `x`
456+ component dropped. Stations whose chord has closed to less than `min_chord_frac` of
457+ the longest one are left out of that range first, so a wing tapering to a point puts
458+ its outermost sections on the last stations that still have an airfoil to slice. The
459+ remaining first and last targets sit a further `wingtip_distance` [m] inboard.
464460"""
465461function station_indices (march, n; wingtip_distance= 0.0 , min_chord_frac= 0.01 )
466462 chords = [norm (te .- le) for (le, te) in zip (march. le, march. te)]
467463 usable = findall (≥ (min_chord_frac * maximum (chords)), chords)
468- arclen = march. arclen
469- inner, outer = arclen[first (usable)], arclen[last (usable)]
464+ quarter_chord = [le .+ 0.25 .* (te .- le) for (le, te) in zip (march. le, march. te)]
465+ span = zeros (length (quarter_chord))
466+ for i in 2 : length (span)
467+ step = quarter_chord[i] .- quarter_chord[i- 1 ]
468+ span[i] = span[i- 1 ] + hypot (step[2 ], step[3 ])
469+ end
470+ inner, outer = span[first (usable)], span[last (usable)]
470471 d = clamp (wingtip_distance, 0.0 , (outer - inner) / 2 )
471- n == 1 && return [argmin (abs .(arclen .- (inner + outer) / 2 ))]
472- return [argmin (abs .(arclen .- t)) for t in range (inner + d, outer - d, n)]
472+ n == 1 && return [argmin (abs .(span .- (inner + outer) / 2 ))]
473+ return [argmin (abs .(span .- t)) for t in range (inner + d, outer - d, n)]
473474end
0 commit comments