package OSCADml
OCaml DSL for 3D solid modelling in OpenSCAD
Install
Dune Dependency
Authors
Maintainers
Sources
OSCADml-0.2.1.tbz
sha256=406e45c5df8122e8b065342e10ba9deb7a066683b256619462c405da69ba5baa
sha512=20db4192d6204d9fd5914562ec83d8edbbb1f5c89a72e61928bf662fdcc9ecea38760b26c99af801ddfc5b877c451ad11c16fc89a6a36ef8c20881375627295b
doc/offset_and_rounding.html
Offsets and roundovers
open OCADml
open OSCADml
Draw a poly
gon and make a pointy
scad from it to compare to our alterations.
let poly = Poly2.make V2.[ v (-4.) 0.; v 5. 3.; v 0. 7.; v 8. 7.; v 20. 20.; v 10. 0. ]
let pointy =
Scad.of_poly2 poly
|> Scad.extrude ~height:1.
|> Scad.translate (v3 0. 0. (-0.5))
|> Scad.color ~alpha:0.5 Color.Silver
Poly2.offset
, and Path2.offset
, are the point representation counterparts of Scad.offset
, so they share the same semantics. For this example, we apply an negative (inward) circular offset.
let () =
Poly2.offset ~mode:`Radius (-0.5) poly
|> Scad.of_poly2
|> Scad.extrude ~height:1.
|> Scad.add pointy
|> Scad.to_file "offset_poly.scad"
More fine-grained control over 2d and 3d path roundovers can be found in the Path2.Round
and Path3.Round
modules respectively. For this example, we'll use the Path2.Round.circles
constructor to create our circular roundover specification with different radii
assigned to each point of the input path Poly2.outer poly
.
let shape_spec =
let radii = [ 1.; 1.5; 0.1; 10.; 0.8; 10. ] in
Path2.Round.circles ~kind:`Radius (List.combine (Poly2.outer poly) radii)
Then we'll apply our Path2.Round.t
shape_spec
with Path2.roundover
, with fn
segments per corner, and compare that to the original pointy
shape.
let () =
Scad.polygon (Path2.roundover ~fn:60 shape_spec)
|> Scad.extrude ~height:1.
|> Scad.add pointy
|> Scad.to_file "circular_rounding.scad"
let () =
let sq = Path3.square ~center:true (v2 2. 2.)
and circ = Path3.(ztrans 2. @@ yrot (Float.pi /. 2.) @@ circle ~fn:32 3.) in
Mesh.hull (List.append sq circ)
|> Scad.of_mesh
|> Scad.(add @@ ztrans 2. @@ sphere ~fn:64 1.1)
|> Scad.to_file "test_hull_3d.scad"
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>