From 36d31ac04ec4e189d0530aacda8bc052f4b4276c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Franze=CC=81n?= Date: Fri, 8 Mar 2024 17:15:04 +0100 Subject: [PATCH] Add Cylinder truncated cone init for radii --- Sources/SwiftSCAD/Shapes/3D/Cylinder.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sources/SwiftSCAD/Shapes/3D/Cylinder.swift b/Sources/SwiftSCAD/Shapes/3D/Cylinder.swift index b65e724..b052bb9 100644 --- a/Sources/SwiftSCAD/Shapes/3D/Cylinder.swift +++ b/Sources/SwiftSCAD/Shapes/3D/Cylinder.swift @@ -54,6 +54,20 @@ public struct Cylinder: CoreGeometry3D { self.centerZ = centerZ } + /// Create a truncated right circular cone (a cylinder with different top and bottom radii) + /// - Parameters: + /// - bottomRadius: The radius at the bottom + /// - topRadius: The radius at the top + /// - height: The height between the top and the bottom + /// - centerZ: If true, center the cylinder along the Z axis + + public init(bottomRadius: Double, topRadius: Double, height: Double, centerZ: Bool = false) { + self.diameter = bottomRadius * 2 + self.topDiameter = topRadius * 2 + self.height = height + self.centerZ = centerZ + } + func call(in environment: Environment) -> SCADCall { var params: [String: any SCADValue] = ["h": height]