package OSCADml

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

Install

Dune Dependency

Authors

Maintainers

Sources

OSCADml-0.2.3.tbz
sha256=61bc12919734a42004f9f54bb03aa5403eac9cdd645cad1fb97ddd2eba148583
sha512=9aca48afeb2c89ace6b07110b6aadedac7d877fb9b0d1990b0c0b622829ff45ced3841fdae30b5b869293dea1b3ae39f1b00fc767c8e3f69d7e78f6412801ffb

doc/arc_points.html

Arcing paths

open OCADml
open OSCADml

A numbered marker function for Debug.show_path2 and Debug.show_path3 that we can use to visualize our arcs (and their ordering).

let show i = Scad.extrude ~height:1. (Scad.text ~size:2. (Printf.sprintf "%i" i))

Draw an arcing path of fn points on the xy plane through the points describing a triangle.

let () =
  let arc = Path2.arc_through ~fn:5 (v2 0. (-10.)) (v2 10. 0.) (v2 0. 10.) in
  Scad.to_file "arc_points_2d.scad" (Debug.show_path2 show arc)

Each of the arc drawing functions takes a wedge parameter that will include the centre point of the arc at the end of the path when true.

let () =
  let arc =
    Path2.arc_about_centre
      ~fn:6
      ~wedge:true
      ~centre:(v2 0. 10.)
      (v2 (-15.) 0.)
      (v2 5. (-5.))
  in
  let wedge = Scad.extrude ~height:1. @@ Scad.of_path2 arc
  and marks =
    Scad.color ~alpha:0.8 Color.Magenta @@ Scad.ztrans 1.1 (Debug.show_path2 show arc)
  in
  Scad.to_file "arc_wedge_2d.scad" @@ Scad.union [ wedge; marks ]

Arcs can also be drawn onto 3d planes other than xy. Here we define a plane from a normal vector, and draw an arc of pi /. 1.5 around the origin from the angle start onto it.

let () =
  let arc =
    Path3.arc
      ~fn:5
      ~plane:(Plane.of_normal (v3 0. (-0.6) 0.4))
      ~centre:V3.zero
      ~radius:10.
      ~start:0.
      (Float.pi *. 1.5)
  in
  Scad.to_file "arc_points_3d.scad" (Debug.show_path3 show arc)

OCaml

Innovation. Community. Security.