|
| 1 | +module VortexStepMethodMakieExt |
| 2 | +using Makie, VortexStepMethod |
| 3 | + |
| 4 | +""" |
| 5 | + plot!(ax, panel::VortexStepMethod.Panel; kwargs...) |
| 6 | +
|
| 7 | +Plot a single `Panel` as a `mesh`. |
| 8 | +The corner points are ordered as: LE1, TE1, TE2, LE2. |
| 9 | +This creates two triangles: (LE1, TE1, TE2) and (LE1, TE2, LE2). |
| 10 | +""" |
| 11 | +function Makie.plot!(ax, panel::VortexStepMethod.Panel; color=(:red, 0.2), R_b_w=nothing, T_b_w=nothing, kwargs...) |
| 12 | + plots = [] |
| 13 | + points = [Point3f(panel.corner_points[:, i]) for i in 1:4] |
| 14 | + if !isnothing(R_b_w) && !isnothing(T_b_w) |
| 15 | + points = [Point3f(R_b_w * p + T_b_w) for p in points] |
| 16 | + end |
| 17 | + faces = [Makie.GLTriangleFace(1, 2, 3), Makie.GLTriangleFace(1, 3, 4)] |
| 18 | + p = mesh!(ax, points, faces; color, transparency=true, kwargs...) |
| 19 | + push!(plots, p) |
| 20 | + border_points = [points..., points[1]] |
| 21 | + p = lines!(ax, border_points; color=:black, transparency=true, kwargs...) |
| 22 | + push!(plots, p) |
| 23 | + return plots |
| 24 | +end |
| 25 | + |
| 26 | +""" |
| 27 | + plot!(ax, body::VortexStepMethod.BodyAerodynamics; kwargs...) |
| 28 | +
|
| 29 | +Plot a `BodyAerodynamics` object by plotting each of its panels. |
| 30 | +""" |
| 31 | +function Makie.plot!(ax, body::VortexStepMethod.BodyAerodynamics; color=(:red, 0.2), R_b_w=nothing, T_b_w=nothing, kwargs...) |
| 32 | + plots = [] |
| 33 | + for panel in body.panels |
| 34 | + p = Makie.plot!(ax, panel; color, R_b_w, T_b_w, kwargs...) |
| 35 | + push!(plots, p) |
| 36 | + end |
| 37 | + return plots |
| 38 | +end |
| 39 | + |
| 40 | +function Makie.plot(panel::VortexStepMethod.Panel; size = (1200, 800), kwargs...) |
| 41 | + fig = Figure(; size) |
| 42 | + ax = Axis3(fig[1, 1]; aspect = :data, |
| 43 | + xlabel = "X", ylabel = "Y", zlabel = "Z", |
| 44 | + azimuth = 9/8*π, zoommode = :cursor, viewmode = :fit, |
| 45 | + ) |
| 46 | + |
| 47 | + plot!(ax, panel; kwargs...) |
| 48 | + return fig |
| 49 | +end |
| 50 | + |
| 51 | +function Makie.plot(body_aero::VortexStepMethod.BodyAerodynamics; size = (1200, 800), |
| 52 | + limitmargin = 0.1, kwargs...) |
| 53 | + fig = Figure(; size) |
| 54 | + ax = Axis3(fig[1, 1]; aspect = :data, |
| 55 | + xlabel = "X", ylabel = "Y", zlabel = "Z", |
| 56 | + azimuth = 9/8*π, zoommode = :cursor, viewmode = :fit, |
| 57 | + xautolimitmargin=(limitmargin, limitmargin), |
| 58 | + yautolimitmargin=(limitmargin, limitmargin), |
| 59 | + zautolimitmargin=(limitmargin, limitmargin), |
| 60 | + ) |
| 61 | + plot!(ax, body_aero; kwargs...) |
| 62 | + return fig |
| 63 | +end |
| 64 | + |
| 65 | +end |
0 commit comments