From 1205666a10030816f615c2d72954af49af9add2d Mon Sep 17 00:00:00 2001 From: Jerome Plut Date: Wed, 9 Mar 2022 18:34:00 +0100 Subject: [PATCH] fixed doc for path_extrude; suggested rename rotate_extrude->revolution --- docs/src/transformations.md | 2 +- src/ConstructiveGeometry.jl | 95 +++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/docs/src/transformations.md b/docs/src/transformations.md index a52d29a..bea0767 100644 --- a/docs/src/transformations.md +++ b/docs/src/transformations.md @@ -147,7 +147,7 @@ png("linear_extrude_twist", s2); # hide ``` ![example: linear extrusion of a L-shape](linear_extrude.png) ![example: linear extrusion with twist](linear_extrude_twist.png) -### Revolution (rotatoinal extrusion) +### Revolution (rotational extrusion) ```@docs rotate_extrude ``` diff --git a/src/ConstructiveGeometry.jl b/src/ConstructiveGeometry.jl index 6182ad3..ac92655 100644 --- a/src/ConstructiveGeometry.jl +++ b/src/ConstructiveGeometry.jl @@ -1023,20 +1023,22 @@ end prism_mesh(g, 0, s.height, s.twist, s.scale, m) """ + prism(h, s...; twist, scale) # preferred form + prism(h; twist, scale) * s linear_extrude(h, s...; twist, scale) linear_extrude(h) * s... -Linear extrusion to height `h`. +Build a prism (linear extrusion) of height `h` on the given base shape. """ -@inline linear_extrude(height, s...; center=false, twist=0, scale=1) = - operator(_linear_extrude, (height, center, twist, scale), s...) -@inline _linear_extrude(h,c,t,s::Real,x) = _linear_extrude(h,c,t,SA[s,s],x) -@inline function _linear_extrude(height, center, twist, scale::AbstractVector, +@inline prism(height, s...; center=false, twist=0, scale=1) = + operator(_prism, (height, center, twist, scale), s...) +@inline _prism(h,c,t,s::Real,x) = _prism(h,c,t,SA[s,s],x) +@inline function _prism(height, center, twist, scale::AbstractVector, s::AbstractGeometry{2}) m = Prism(height, twist, scale, s) center ? translate([0,0,-one_half(height)], m) : m end -@inline prism(height, s...; kwargs...) = linear_extrude(height, s...; kwargs...) +linear_extrude = prism # Cylinder ««2 # cylinder(h, (r1, r2) [, center=false]) @@ -1059,13 +1061,13 @@ and inscribed otherwise. """ @inline cylinder(h::Real, r::Real;center::Bool=false, circumscribed=false) = - let c = linear_extrude(h)*circle(r;circumscribed) + let c = prism(h)*circle(r;circumscribed) center ? lower(one_half(h))*c : c end function cylinder(h::Real, r1::Real, r2::Real; center::Bool = false, circumscribed=false) a1, a2 = minmax(r1, r2) - m = linear_extrude(h, scale=a1/a2)*circle(a2;circumscribed) + m = prism(h, scale=a1/a2)*circle(a2;circumscribed) b = 2(r1