package OSCADml
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=61bc12919734a42004f9f54bb03aa5403eac9cdd645cad1fb97ddd2eba148583
sha512=9aca48afeb2c89ace6b07110b6aadedac7d877fb9b0d1990b0c0b622829ff45ced3841fdae30b5b869293dea1b3ae39f1b00fc767c8e3f69d7e78f6412801ffb
doc/polar_rose.html
Polar Rose
open OCADml
open OSCADml
Define a function that takes a radius r
and angle a
, and returns a z coordinate. This rose function is ported from the examples given in the plot function OpenSCAD library.
let rose ~r ~a =
let open Float in
let x =
pow
( (r *. cos a *. cos (r *. 8. *. pi /. 180.))
+. (r *. sin a *. sin (r *. 35. *. pi /. 180.)) )
2.
/. -300.
in
((15. +. (5. *. sin (r *. 10. *. pi /. 180.))) *. exp x) +. 1.
Starting from the origin, step outward radially with r_step
increments up to a maximal radius of max_r
. For each of these radii, rose
will be evaluated with angles revolving around the z-axis, evaluating to the height off of the XY plane that that position should be.
let mesh = Mesh.polar_plot ~r_step:0.2 ~max_r:22. rose
As the generated mesh contains quite a large number of points due to the relatively low value of r_step
(megabytes), we'll take advantage of the include
trick provided by the optional ?incl
parameter to Scad.to_file
. This will produce a pair of .scad
scripts, one named "incl_polar_rose.scad"
, and another named "polar_rose.scad"
that simply includes it. By loading the later into OpenSCAD rather than the former, we can avoid the sluggishness that can result when the editor attempts to handle large files.
let () = Scad.to_file ~incl:true "polar_rose.scad" (Scad.of_mesh mesh)