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/resampled_path.html
Path resampling and scaling/twisting sweeps
open OCADml
open OSCADml
Oftentimes, we would just like to define our paths without colinear points, such that it only consists of corners. However, some applications call for more fine sampling, and in those times we can reach for Path3.resample
or Path3.subdivide
. For this example, the exact number of points isn't a concern, so we'll specify a new point spacing as our ~freq
.
let path = [ v3 0. 0. 0.; v3 5. 5. 5.; v3 5. 5. 15. ]
let resampled = Path3.subdivide ~freq:(`Spacing 0.5) path
Lets visualize our original path
, and the resampled
points with Debug.show_path3
to get a sense of how fine our ~freq
parameter has gotten us.
let () =
let old_marks =
let f _ = Scad.(color ~alpha:0.2 Color.Magenta @@ sphere ~fn:36 0.4) in
Debug.show_path3 f path
and new_marks = Debug.show_path3 (fun _ -> Scad.sphere ~fn:36 0.2) resampled in
Scad.to_file "resampled_path.scad" (Scad.union [ old_marks; new_marks ])
One such alluded to application for resampling, is when additional transformations such as scaling and twisting along a path extrusion is desired.
let () =
let mesh =
Mesh.path_extrude
~scale_ez:(v2 0.42 0., v2 1. 1.)
~twist_ez:(v2 0.42 0., v2 1. 1.)
~scale:(v2 4. 1.)
~twist:(Float.pi *. 4.)
~path:resampled
@@ Poly2.square ~center:true (v2 1. 0.5)
in
Scad.to_file "scaling_twister_extrude.scad" (Scad.of_mesh mesh)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>