package OSCADml

  1. Overview
  2. Docs
OCaml DSL for 3D solid modelling in OpenSCAD

Install

Dune Dependency

Authors

Maintainers

Sources

OSCADml-0.2.2.tbz
sha256=8c0eeb5055dd16bb0f9b25b4d21d5312c431969fd0871fc045df2f93147ae39a
sha512=b28bd304ef3196193ba6fe33f51f0f1e2c6bb3cd41c47335a513d9fb4b1f5eca8bcbabcf8683d9b35e3cbd4f3dabe2c7bcc8f5c4b087f96a7ac70117fc4babfa

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)

OCaml

Innovation. Community. Security.