-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bezier skline example + other example touchups
Bumps OCADml dep to v0.6.0 in order to add a skline example. Now that OCADml has direct stl export though, I need to consider moving the examples under that library. Or, just replicate what currently exists for now, and don't add further examples here (which are really OCADml mesh generations without CSG) while I consider if this manual should be trimmed down to something more OpenSCAD centric.
- Loading branch information
Showing
45 changed files
with
206 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ _opam/ | |
_esy/ | ||
|
||
examples/scads | ||
examples/pngs/incl_*.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ authors: [ | |
"Masaki Nakano<[email protected]>" | ||
] | ||
license: "GPL-2.0-or-later" | ||
tags: ["OCADml" "CAD" "OpenSCAD"] | ||
tags: ["OCADml" "CAD" "OpenSCAD" "CSG"] | ||
homepage: "https://github.com/OCADml/OSCADml" | ||
doc: "https://ocadml.github.io/OSCADml" | ||
bug-reports: "https://github.com/OCADml/OSCADml/issues" | ||
|
@@ -18,7 +18,7 @@ depends: [ | |
"ocaml" {>= "4.14.0"} | ||
"gg" {>= "1.0.0"} | ||
"cairo2" {>= "0.6.2"} | ||
"OCADml" {>= "0.5.0"} | ||
"OCADml" {>= "0.6.0"} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{0 Bézier Sklines} | ||
|
||
{[ | ||
open OCADml | ||
open OSCADml | ||
]} | ||
|
||
{{!OCADml.Mesh.skline} [Mesh.skline]}, like {{!OCADml.Mesh.skin} | ||
[Mesh.skin]} provides a means of generating a mesh that covers a series of | ||
given profiles, but where [skin] linearly transistions between each profile | ||
independently, [skline] splines through each of the paths formed by the | ||
associated vertices from the first profile to the last (or in a loop). | ||
to generate meshes that cover over series of profiles. However, unlike | ||
[skin] only resampling is made available for mapping vertices between | ||
incomensurate profiles as the point duplication methods (tangent and | ||
distance) can easily lead to edge intersections. | ||
|
||
{[ | ||
let handle_profiles = | ||
let circ = Path3.circle ~fn:64 5. in | ||
let base = Path3.scale (v3 1.2 1.2 1.) circ | ||
and handle = Path3.scale (v3 0.7 0.7 1.) circ in | ||
Path3. | ||
[ ztrans (-3.) base | ||
; circ | ||
; translate (v3 15. 0. 20.) (yrot (Float.pi /. 2.) handle) | ||
; xtrans 30. (yrot Float.pi circ) | ||
; translate (v3 30. 0. (-3.)) (yrot Float.pi base) | ||
] | ||
]} | ||
|
||
A quick look at the points of our profiles we are about to spline over with | ||
alternating colours may help a bit to conceptualize what we are about to | ||
give {{!OCADml.Mesh.skline} [Mesh.skline]} to work with. | ||
|
||
{[ | ||
let () = | ||
let show i = | ||
let c = if i mod 2 = 0 then Color.Magenta else Color.Aquamarine in | ||
Debug.show_path3 (fun _ -> Scad.(color c @@ sphere 0.2)) | ||
in | ||
List.mapi show handle_profiles |> Scad.union |> Scad.to_file "handle_points.scad" | ||
]} | ||
|
||
{%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/handle_points.png" style="width:150mm;"/> | ||
</p> %} | ||
|
||
Using the [?tangents] parameter of {{!OCADml.Bezier3.of_path} | ||
[Bezier3.of_path]} we can specify the tangents we want for each profile, | ||
rather than leaving them up to the automatically computed derivatives (that | ||
may differ for each edge path tracing between the profiles). Here we | ||
contstrain them to cardinals so we can get a handle that sticks closer to | ||
right angles. | ||
|
||
{[ | ||
let () = | ||
let up = v3 0. 0. 1. in | ||
let tangents = `Tangents [ up; up; v3 1. 0. 0.; V3.neg up; V3.neg up ] in | ||
Mesh.skline ~fn:200 ~size:(`Flat (`Rel 0.5)) ~tangents handle_profiles | ||
|> Scad.of_mesh | ||
|> Scad.to_file ~incl:true "handle_skline.scad" | ||
]} | ||
|
||
{%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/handle_skline.png" style="width:150mm;"/> | ||
</p> %} | ||
|
||
As mentioned above, continuous curvature loops are also possible. Here we | ||
morph cyclically through circular and pentagonal profiles by specifying | ||
[~endcaps:`Loop]. | ||
|
||
{[ | ||
let () = | ||
let circ = Path3.circle ~fn:64 5. in | ||
let pent = Path3.(circle ~fn:5 5.) in | ||
let profs = | ||
Path3. | ||
[ circ | ||
; translate (v3 15. 0. 20.) (yrot (Float.pi /. 2.) pent) | ||
; xtrans 30. (yrot Float.pi circ) | ||
; translate (v3 15. 0. (-20.)) (yrot (Float.pi *. 1.5) pent) | ||
] | ||
in | ||
Mesh.skline ~endcaps:`Loop ~fn:200 ~size:(`Flat (`Rel 0.1)) profs | ||
|> Scad.of_mesh | ||
|> Scad.to_file ~incl:true "edgy_loop.scad" | ||
]} | ||
|
||
{%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/edgy_loop.png" style="width:150mm;"/> | ||
</p> %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
(** {0 Bézier Sklines} *) | ||
|
||
open OCADml | ||
open OSCADml | ||
|
||
(** {{!OCADml.Mesh.skline} [Mesh.skline]}, like {{!OCADml.Mesh.skin} | ||
[Mesh.skin]} provides a means of generating a mesh that covers a series of | ||
given profiles, but where [skin] linearly transistions between each profile | ||
independently, [skline] splines through each of the paths formed by the | ||
associated vertices from the first profile to the last (or in a loop). | ||
to generate meshes that cover over series of profiles. However, unlike | ||
[skin] only resampling is made available for mapping vertices between | ||
incomensurate profiles as the point duplication methods (tangent and | ||
distance) can easily lead to edge intersections. *) | ||
|
||
let handle_profiles = | ||
let circ = Path3.circle ~fn:64 5. in | ||
let base = Path3.scale (v3 1.2 1.2 1.) circ | ||
and handle = Path3.scale (v3 0.7 0.7 1.) circ in | ||
Path3. | ||
[ ztrans (-3.) base | ||
; circ | ||
; translate (v3 15. 0. 20.) (yrot (Float.pi /. 2.) handle) | ||
; xtrans 30. (yrot Float.pi circ) | ||
; translate (v3 30. 0. (-3.)) (yrot Float.pi base) | ||
] | ||
|
||
(** A quick look at the points of our profiles we are about to spline over with | ||
alternating colours may help a bit to conceptualize what we are about to | ||
give {{!OCADml.Mesh.skline} [Mesh.skline]} to work with. *) | ||
let () = | ||
let show i = | ||
let c = if i mod 2 = 0 then Color.Magenta else Color.Aquamarine in | ||
Debug.show_path3 (fun _ -> Scad.(color c @@ sphere 0.2)) | ||
in | ||
List.mapi show handle_profiles |> Scad.union |> Scad.to_file "handle_points.scad" | ||
|
||
(** {%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/handle_points.png" style="width:150mm;"/> | ||
</p> %} | ||
*) | ||
|
||
(** Using the [?tangents] parameter of {{!OCADml.Bezier3.of_path} | ||
[Bezier3.of_path]} we can specify the tangents we want for each profile, | ||
rather than leaving them up to the automatically computed derivatives (that | ||
may differ for each edge path tracing between the profiles). Here we | ||
contstrain them to cardinals so we can get a handle that sticks closer to | ||
right angles. *) | ||
|
||
let () = | ||
let up = v3 0. 0. 1. in | ||
let tangents = `Tangents [ up; up; v3 1. 0. 0.; V3.neg up; V3.neg up ] in | ||
Mesh.skline ~fn:200 ~size:(`Flat (`Rel 0.5)) ~tangents handle_profiles | ||
|> Scad.of_mesh | ||
|> Scad.to_file ~incl:true "handle_skline.scad" | ||
|
||
(** {%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/handle_skline.png" style="width:150mm;"/> | ||
</p> %} | ||
*) | ||
|
||
(** As mentioned above, continuous curvature loops are also possible. Here we | ||
morph cyclically through circular and pentagonal profiles by specifying | ||
[~endcaps:`Loop]. *) | ||
|
||
let () = | ||
let circ = Path3.circle ~fn:64 5. in | ||
let pent = Path3.(circle ~fn:5 5.) in | ||
let profs = | ||
Path3. | ||
[ circ | ||
; translate (v3 15. 0. 20.) (yrot (Float.pi /. 2.) pent) | ||
; xtrans 30. (yrot Float.pi circ) | ||
; translate (v3 15. 0. (-20.)) (yrot (Float.pi *. 1.5) pent) | ||
] | ||
in | ||
Mesh.skline ~endcaps:`Loop ~fn:200 ~size:(`Flat (`Rel 0.1)) profs | ||
|> Scad.of_mesh | ||
|> Scad.to_file ~incl:true "edgy_loop.scad" | ||
|
||
(** {%html: | ||
<p style="text-align:center;"> | ||
<img src="_assets/edgy_loop.png" style="width:150mm;"/> | ||
</p> %} | ||
*) |