From ce4f58a06a07d9f4f3826449de5a5a791eb85f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 14:35:23 +0300 Subject: [PATCH 01/15] Define the ConicalFrustum type --- src/GeometryBasics.jl | 3 +- src/primitives/ConicalFrustum.jl | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/primitives/ConicalFrustum.jl diff --git a/src/GeometryBasics.jl b/src/GeometryBasics.jl index d01865ae..b00e23ff 100644 --- a/src/GeometryBasics.jl +++ b/src/GeometryBasics.jl @@ -17,6 +17,7 @@ include("primitives/cylinders.jl") include("primitives/pyramids.jl") include("primitives/particles.jl") include("primitives/Cone.jl") +include("primitives/ConicalFrustum.jl") include("interfaces.jl") include("viewtypes.jl") @@ -68,7 +69,7 @@ if Base.VERSION >= v"1.8" include("precompiles.jl") end -# Needed for GeometryBasicsGeoInterfaceExt. +# Needed for GeometryBasicsGeoInterfaceExt. # In future this can go away as can use Module dispatch. function geointerface_geomtype end diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl new file mode 100644 index 00000000..31705074 --- /dev/null +++ b/src/primitives/ConicalFrustum.jl @@ -0,0 +1,54 @@ +""" +A type that represents a conical frustum: a cone whose top has been cut off such, +that the intersection of the cutting plane and the cone is a circle. +""" +struct ConicalFrustum{T} <: GeometryPrimitive{3,T} + + """ + The center point of the circular base. + """ + baseCenter :: Point3{T} + """ + The radius of the bottom circle. + """ + baseRadius :: T + + """ + The center of the top circle. + """ + topCenter :: Point3{T} + + """ + The radius of the top circle. + """ + topRadius :: T + + """ + An inner constructor that validates the input values. + """ + function ConicalFrustum(baseCenter,baseRadius,topCenter,topRadius) + + baseRadius > 0 ? nothing : throw(ArgumentError("The base radius of a conical frustum needs to be positive.")) + + isfinite(baseRadius) ? nothing : throw(ArgumentError("The base radius of a conical frustum needs to be finite.")) + + topRadius > 0 ? nothing : throw(ArgumentError("The top radius of a conical frustum needs to be positive.")) + + isfinite(topRadius) ? nothing : throw(ArgumentError("The top radius of a conical frustum needs to be finite.")) + + new(baseCenter,baseRadius,topCenter,topRadius) + + end # function + +end # struct + +""" +An external constructor for converting inputs of different eltypes to a common type. +""" +function ConicalFrustum(baseCenter::Point3{T1},baseRadius::T2,topCenter::Point3{T3},topRadius::T4) where {T1,T2,T3,T4} + + T = promote_type(T1,T2,T3,T4) + + ConicalFrustum{T}(baseCenter,baseRadius,topCenter,topRadius) + +end # function From 402473ba2d656d2f88f63337d61714b441dda549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 14:39:38 +0300 Subject: [PATCH 02/15] ConicalFrustum: add missing type parameter to inner constructor --- src/primitives/ConicalFrustum.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 31705074..c6ec2772 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -26,7 +26,7 @@ struct ConicalFrustum{T} <: GeometryPrimitive{3,T} """ An inner constructor that validates the input values. """ - function ConicalFrustum(baseCenter,baseRadius,topCenter,topRadius) + function ConicalFrustum{T}(baseCenter,baseRadius,topCenter,topRadius) where T baseRadius > 0 ? nothing : throw(ArgumentError("The base radius of a conical frustum needs to be positive.")) @@ -36,7 +36,7 @@ struct ConicalFrustum{T} <: GeometryPrimitive{3,T} isfinite(topRadius) ? nothing : throw(ArgumentError("The top radius of a conical frustum needs to be finite.")) - new(baseCenter,baseRadius,topCenter,topRadius) + new{T}(baseCenter,baseRadius,topCenter,topRadius) end # function From 867640a64e2bc9af497077c4c052c1ca44211142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 14:54:22 +0300 Subject: [PATCH 03/15] Add external convenience constructors for creating ConicalFrustums from arrays and tuples --- src/primitives/ConicalFrustum.jl | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index c6ec2772..f445928f 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -52,3 +52,44 @@ function ConicalFrustum(baseCenter::Point3{T1},baseRadius::T2,topCenter::Point3{ ConicalFrustum{T}(baseCenter,baseRadius,topCenter,topRadius) end # function + +""" +An external convenience constructor for creating instances from arrays instead of having to exlicitly create points. +""" +function ConicalFrustum(baseCenter::AbstractArray{T1},baseRadius::T2,topCenter::AbstractArray{T3},topRadius::T4) where {T1,T2,T3,T4} + + baseCenterPoint = Point3{T1}(baseCenter) + + topCenterPoint = Point3{T3}(topCenter) + + ConicalFrustum(baseCenterPoint,baseRadius,topCenterPoint,topRadius) + +end # function + +""" +An external convenience constructor for creating instances from NTuples instead of having to exlicitly create points. +""" +function ConicalFrustum(baseCenter::NTuple{3,T1},baseRadius::T2,topCenter::NTuple{3,T3},topRadius::T4) where {T1,T2,T3,T4} + + baseCenterPoint = Point3{T1}(baseCenter) + + topCenterPoint = Point3{T3}(topCenter) + + ConicalFrustum(baseCenterPoint,baseRadius,topCenterPoint,topRadius) + +end # function + +""" +An external convenience constructor for creating instances from Tuples instead of having to exlicitly create points. +""" +function ConicalFrustum(baseCenter::Tuple{T1,T2,T3},baseRadius::T4,topCenter::Tuple{T4,T5,T6},topRadius::T7) where {T1,T2,T3,T4,T5,T6,T7} + + T = promote_type(T1,T2,T3,T4,T5,T6,T7) + + baseCenterPoint = Point3{T}(baseCenter) + + topCenterPoint = Point3{T}(topCenter) + + ConicalFrustum(baseCenterPoint,baseRadius,topCenterPoint,topRadius) + +end # function From a60265263b27ac294ba25beb84599b483c8c2b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 15:03:12 +0300 Subject: [PATCH 04/15] ConicalFrustum: add validations for bottom and top centers in inner constructor --- src/primitives/ConicalFrustum.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index f445928f..02b5e069 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -28,6 +28,10 @@ struct ConicalFrustum{T} <: GeometryPrimitive{3,T} """ function ConicalFrustum{T}(baseCenter,baseRadius,topCenter,topRadius) where T + all(isfinite.(baseCenter)) ? nothing : throw(ArgumentError("The bottom circle center point of a conical frustum needs to have finite coordinates and be a number.")) + + all(isfinite.(topCenter)) ? nothing : throw(ArgumentError("The top circle center point of a conical frustum needs to have finite coordinates and be a number.")) + baseRadius > 0 ? nothing : throw(ArgumentError("The base radius of a conical frustum needs to be positive.")) isfinite(baseRadius) ? nothing : throw(ArgumentError("The base radius of a conical frustum needs to be finite.")) From ea8a51f40bb6ceb0a0dc671c65ab553917b62cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 15:30:22 +0300 Subject: [PATCH 05/15] ConicalFrustum: add functions for accessing fields and computing length, areas and volume --- src/primitives/ConicalFrustum.jl | 79 ++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 02b5e069..5813ab76 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -97,3 +97,82 @@ function ConicalFrustum(baseCenter::Tuple{T1,T2,T3},baseRadius::T4,topCenter::Tu ConicalFrustum(baseCenterPoint,baseRadius,topCenterPoint,topRadius) end # function + +# Accessor functions for frustum fields. + +""" +An accessor function for a base center. +""" +baseCenter(x::ConicalFrustum) = x.baseCenter + +""" +An accessor function for base radius. +""" +baseRadius(x::ConicalFrustum) = x.baseRadius + +""" +An accessor function for top center. +""" +topCenter(x::ConicalFrustum) = x.topCenter + +""" +An accessor function for top radius. +""" +topRadius(x::ConicalFrustum) = x.topRadius + +# Functions for computing derived properties based on type field values. + +""" +Computes the length of a frustum as the norm of the difference of its top and base centers. +""" +Base.length(x::ConicalFrustum) = LinearAlgebra.norm(topCenter(x) - baseCenter(x)) + +""" +Computes the area of the base of a given conical frustum. +""" +baseArea(x::ConicalFrustum) = pi * baseRadius(x) ^ 2 + +""" +Computes the area of the top of a given conical frustum. +""" +topArea(x::ConicalFrustum) = pi * topRadius(x) ^ 2 + +""" +Computes the slant length of a conical frustum. +""" +slantLength(x::ConicalFrustum) = sqrt( ( baseArea(x) - topArea(x) ) ^ 2 + length(x) ^ 2 ) + +""" +Computes the surface area of a frustum not including the top and bottom areas. +""" +function slantArea(x::ConicalFrustum) + + baseRadiusVal = baseRadius(x) + + topRadiusVal = topRadius(x) + + lengthVal = length(x) + + pi * (baseRadiusVal + topRadiusVal) * slantLength(x) + +end # function + +""" +Computes the total surface area of a conical frustum. +""" +surfaceArea(x::ConicalFrustum) = baseArea(x) + topArea(x) + slantArea(x) + +""" +Computes the volume of a conical frustum. +""" +function volume(x::ConicalFrustum) + + baseRadiusVal = baseRadius(x) + + topRadiusVal = topRadius(x) + + lengthVal = length(x) + + pi * lengthVal * ( baseRadiusVal ^ 2 + baseRadiusVal * topRadiusVal + topRadiusVal ^ 2 )/ 3 + +end # function From 865824322afaf70882c35b664ecda48caa6798f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 15:32:22 +0300 Subject: [PATCH 06/15] ConicalFrustum: add a missing space between binary operator and operand --- src/primitives/ConicalFrustum.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 5813ab76..978dd3ec 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -173,6 +173,6 @@ function volume(x::ConicalFrustum) lengthVal = length(x) - pi * lengthVal * ( baseRadiusVal ^ 2 + baseRadiusVal * topRadiusVal + topRadiusVal ^ 2 )/ 3 + pi * lengthVal * ( baseRadiusVal ^ 2 + baseRadiusVal * topRadiusVal + topRadiusVal ^ 2 ) / 3 end # function From 45eef9100fd4e112c67111d66d9ca86ec3eeb995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 15:36:02 +0300 Subject: [PATCH 07/15] ConicalFrustum: define centroid function --- src/primitives/ConicalFrustum.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 978dd3ec..9a9da0db 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -176,3 +176,8 @@ function volume(x::ConicalFrustum) pi * lengthVal * ( baseRadiusVal ^ 2 + baseRadiusVal * topRadiusVal + topRadiusVal ^ 2 ) / 3 end # function + +""" +Computes the centroid of a frustum: the mean between the base and top centers. +""" +centroid(x::ConicalFrustum) = (baseCenter(x) + topCenter(x)) / 2 From 752f30d4bad047d484d01390cd77b7ed48e2f558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 16 Aug 2025 15:41:00 +0300 Subject: [PATCH 08/15] ConicalFrustum: change calls of {base,top}Area to {base,top}Radius in slantHeight This was a typo. --- src/primitives/ConicalFrustum.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 9a9da0db..b762270e 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -140,7 +140,7 @@ topArea(x::ConicalFrustum) = pi * topRadius(x) ^ 2 """ Computes the slant length of a conical frustum. """ -slantLength(x::ConicalFrustum) = sqrt( ( baseArea(x) - topArea(x) ) ^ 2 + length(x) ^ 2 ) +slantLength(x::ConicalFrustum) = sqrt( ( baseRadius(x) - topRadius(x) ) ^ 2 + length(x) ^ 2 ) """ Computes the surface area of a frustum not including the top and bottom areas. From 8a32b7cb76c6611f95c8b514a7bd7378fb1e9329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Mon, 18 Aug 2025 09:18:39 +0300 Subject: [PATCH 09/15] ConicalFrustum: add a line break to type definition for consistency --- src/primitives/ConicalFrustum.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index b762270e..fe6b5d9f 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -8,6 +8,7 @@ struct ConicalFrustum{T} <: GeometryPrimitive{3,T} The center point of the circular base. """ baseCenter :: Point3{T} + """ The radius of the bottom circle. """ From 6a9e94dc19d4f4dc15ea2256164dcba4de84d8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 12:33:12 +0300 Subject: [PATCH 10/15] Define function coordinates(::ConicalFrustum, ...) --- src/primitives/ConicalFrustum.jl | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index fe6b5d9f..249f314e 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -182,3 +182,56 @@ end # function Computes the centroid of a frustum: the mean between the base and top centers. """ centroid(x::ConicalFrustum) = (baseCenter(x) + topCenter(x)) / 2 + +""" +Computes the coordinates required for the discretization +of a frustum. The logic is the same as that for a cylinder, +where the top and bottom circles are approximated using +a polygon. +""" +function coordinates(c::ConicalFrustum{T}, nvertices=30) where {T} + + nvertices += isodd(nvertices) + + nhalf = div(nvertices, 2) + + R = rotation(c) + + step = 2pi / nhalf + + ps = Vector{Point3{T}}(undef, nvertices + 2) + + baseRadiusVal = baseRadius(c) + + baseCenterVal = baseCenter(c) + + topRadiusVal = topRadius(c) + + topCenterVal = topCenter(c) + + # First discretize the base... + + for i in 1:nhalf + + phi = (i-1) * step + + ps[i] = R * Point3{T}(baseRadius * cos(phi), baseRadius * sin(phi), 0) + baseCenterVal + + end + + # ... and then the top circle. + + for i in 1:nhalf + + phi = (i-1) * step + + ps[i + nhalf] = R * Point3{T}(topRadiusVal * cos(phi), topRadiusVal * sin(phi), 0) + topCenterVal + end + + ps[end-1] = baseCenterVal + + ps[end] = topCenterVal + + return ps + +end # function From 3671893e0e55e2a95b1a96714d7e56f318cc3846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 13:08:12 +0300 Subject: [PATCH 11/15] Define method direction(x::ConicalFrustum) --- src/primitives/ConicalFrustum.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index 249f314e..abdf1e88 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -123,10 +123,15 @@ topRadius(x::ConicalFrustum) = x.topRadius # Functions for computing derived properties based on type field values. +""" +Computes the direction of a frustum, the difference between its top and base centers. +""" +direction(x::ConicalFrustum) = topCenter(x) - baseCenter(x) + """ Computes the length of a frustum as the norm of the difference of its top and base centers. """ -Base.length(x::ConicalFrustum) = LinearAlgebra.norm(topCenter(x) - baseCenter(x)) +Base.length(x::ConicalFrustum) = LinearAlgebra.norm(direction(x)) """ Computes the area of the base of a given conical frustum. From 370d7eeda8fe8889234130349b9a3e3c3075ba4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 13:15:10 +0300 Subject: [PATCH 12/15] ConicalFrustum: fix variable name in coordinates method --- src/primitives/ConicalFrustum.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index abdf1e88..abeed946 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -220,7 +220,7 @@ function coordinates(c::ConicalFrustum{T}, nvertices=30) where {T} phi = (i-1) * step - ps[i] = R * Point3{T}(baseRadius * cos(phi), baseRadius * sin(phi), 0) + baseCenterVal + ps[i] = R * Point3{T}(baseRadiusVal * cos(phi), baseRadiusVal * sin(phi), 0) + baseCenterVal end From ac0c4e4eab2e64bfcef5892839e73f72f58da5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 13:21:15 +0300 Subject: [PATCH 13/15] Define method faces(::ConicalFrustum, ...) --- src/primitives/ConicalFrustum.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index abeed946..a30c0233 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -240,3 +240,22 @@ function coordinates(c::ConicalFrustum{T}, nvertices=30) where {T} return ps end # function + +""" +Computes the facial indices of a conical frustum, +that can be used to index into the coordinates produced by the coordinates function. +Again, follows the same logic as cylinders. +""" +function faces(::ConicalFrustum, facets=30) + nvertices = facets + isodd(facets) + nhalf = div(nvertices, 2) + + disk1 = map(i -> GLTriangleFace(nvertices+1, mod1(i+1, nhalf), i), 1:nhalf) + mantle = map(1:nhalf) do i + i1 = mod1(i+1, nhalf) + QuadFace(i, i1, i1 + nhalf, i+nhalf) + end + disk2 = map(i -> GLTriangleFace(nvertices+2, i+nhalf, mod1(i+1, nhalf)+nhalf), 1:nhalf) + + return vcat(disk1, mantle, disk2) +end From a67d57a0340e65e9aa188bb1e78c559ba9b72eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 13:27:53 +0300 Subject: [PATCH 14/15] Add method normals(c::ConicalFrustum, ...) --- src/primitives/ConicalFrustum.jl | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index a30c0233..c8d69a5b 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -241,6 +241,46 @@ function coordinates(c::ConicalFrustum{T}, nvertices=30) where {T} end # function +""" +Computes the surface normals of the discrtization of a conical frustum. +Follows the same logic as cylinders. +""" +function normals(c::ConicalFrustum, nvertices = 30) + + nvertices += isodd(nvertices) + + nhalf = div(nvertices, 2) + + R = rotation(c) + + step = 2pi / nhalf + + ns = Vector{Vec3f}(undef, nhalf + 2) + + for i in 1:nhalf + + phi = (i-1) * step + + ns[i] = R * Vec3f(cos(phi), sin(phi), 0) + + end + + ns[end-1] = R * Vec3f(0, 0, -1) + + ns[end] = R * Vec3f(0, 0, 1) + + disk1 = map(i -> GLTriangleFace(nhalf+1), 1:nhalf) + + mantle = map(i -> QuadFace(i, mod1(i+1, nhalf), mod1(i+1, nhalf), i), 1:nhalf) + + disk2 = map(i -> GLTriangleFace(nhalf+2), 1:nhalf) + + fs = vcat(disk1, mantle, disk2) + + return FaceView(ns, fs) + +end + """ Computes the facial indices of a conical frustum, that can be used to index into the coordinates produced by the coordinates function. From 235b3c1cd7656f5b93f619faa14757fe71bfaf8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santtu=20S=C3=B6derholm?= Date: Sat, 23 Aug 2025 13:29:36 +0300 Subject: [PATCH 15/15] ConicalFrustum: rename "slant" to "mantle" --- src/primitives/ConicalFrustum.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/primitives/ConicalFrustum.jl b/src/primitives/ConicalFrustum.jl index c8d69a5b..53719f6d 100644 --- a/src/primitives/ConicalFrustum.jl +++ b/src/primitives/ConicalFrustum.jl @@ -144,14 +144,14 @@ Computes the area of the top of a given conical frustum. topArea(x::ConicalFrustum) = pi * topRadius(x) ^ 2 """ -Computes the slant length of a conical frustum. +Computes the mantle length of a conical frustum. """ -slantLength(x::ConicalFrustum) = sqrt( ( baseRadius(x) - topRadius(x) ) ^ 2 + length(x) ^ 2 ) +mantleLength(x::ConicalFrustum) = sqrt( ( baseRadius(x) - topRadius(x) ) ^ 2 + length(x) ^ 2 ) """ Computes the surface area of a frustum not including the top and bottom areas. """ -function slantArea(x::ConicalFrustum) +function mantleArea(x::ConicalFrustum) baseRadiusVal = baseRadius(x) @@ -159,14 +159,14 @@ function slantArea(x::ConicalFrustum) lengthVal = length(x) - pi * (baseRadiusVal + topRadiusVal) * slantLength(x) + pi * (baseRadiusVal + topRadiusVal) * mantleLength(x) end # function """ Computes the total surface area of a conical frustum. """ -surfaceArea(x::ConicalFrustum) = baseArea(x) + topArea(x) + slantArea(x) +surfaceArea(x::ConicalFrustum) = baseArea(x) + topArea(x) + mantleArea(x) """ Computes the volume of a conical frustum.