From a3d18152e92ff7729f7165e2fd35e1ff548e4129 Mon Sep 17 00:00:00 2001 From: Richard Milewski Date: Tue, 1 Oct 2024 13:03:47 -0700 Subject: [PATCH] =?UTF-8?q?Delete=20B=C3=A9ziers=5Ffor=5FBeginners.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tutorials/docs/Béziers_for_Beginners.md | 213 ----------------------- 1 file changed, 213 deletions(-) delete mode 100644 tutorials/docs/Béziers_for_Beginners.md diff --git a/tutorials/docs/Béziers_for_Beginners.md b/tutorials/docs/Béziers_for_Beginners.md deleted file mode 100644 index 24b7d8d..0000000 --- a/tutorials/docs/Béziers_for_Beginners.md +++ /dev/null @@ -1,213 +0,0 @@ -# Béziers for Beginners - - - -Bézier curves are parametric curves defined by a set of control points. They are based on the [polynomials](https://en.wikipedia.org/wiki/Bernstein_polynomial) developed by [Sergei Natanovich Bernstein](https://en.wikipedia.org/wiki/Sergei_Natanovich_Bernstein) in 1912. - -In 1959 [Paul de Casteljau](https://en.wikipedia.org/wiki/Paul_de_Casteljau) developed [de Casteljau's algorithm](https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm), to create the curves and applied them to computer-aided design at French automaker Citroën. De Casteljau's method was not published until the 1980s. In the 1960s, [Pierre Bézier](https://en.wikipedia.org/wiki/Pierre_B%C3%A9zier), discovered the method independently and used them to design auto bodies at Renault a competing french automobile company. Bézier's method was widely popularized and the curves bear his name to this day. - -The positions of the Bézier control points in relation to one another define the shape of the curve. The simplest cubic Bézier curves have 4 control points. The first and last control points are the endpoints of the curve. The curve starts in the direction of the second control point and then turns so that it arrives at the endpoint from the direction of the third control point. - -To work with Béziers in OpenSCAD we need to load the Bézier extension BOSL2/beziers.scad in addition to BOSL2/std.scad. - -In OpenSCAD the control points of a Bézier curve are contained in a list. - -To visualize a Bézier curve we can use the module [debug_bezier()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#module-debug_bezier). - -```openscad -include -include - -bez = [[15,0], [35,40], [-15,60], [20,80]]; -debug_bezier(bez); -``` -![Figure 1](images/Béziers_for_Beginners_1.png) - -By moving the second and third points on the list we change the shape of the curve. - -```openscad -include -include - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -debug_bezier(bez); -``` -![Figure 2](images/Béziers_for_Beginners_2.png) - -While bez in our example is a list of points, it is not the same as OpenScad path, which is also a list of points. - -```openscad -include -include - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -debug_bezier(bez); -color("red") stroke(bez); - -``` -![Figure 3](images/Béziers_for_Beginners_3.png) - - - - We can use the [bezpath_curve()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_curve) function to convert the Bézier curve to an OpenSCAD path. - -```openscad -include -include - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -path = bezpath_curve(bez); -stroke(path); -``` -![Figure 4](images/Béziers_for_Beginners_4.png) - -By default [bezpath_curve()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_curve) splits the Bézier curve into 16 straight-line segments. Note that the special variable $FN has no effect on the number of steps. You can control this number using the splinesteps argument. - -```openscad -include -include - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -path = bezpath_curve(bez, splinesteps = 6); -stroke(path); -``` -![Figure 5](images/Béziers_for_Beginners_5.png) - - - -To close the path to the x-axis we can use the [bezpath\_close\_to\_axis()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_close_to_axis) function. - - -************** - -```openscad -include -include - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -closed = bezpath_close_to_axis(bez, axis = "Y"); -path = bezpath_curve(closed); -stroke(path); -``` -![Figure 6](images/Béziers_for_Beginners_6.png) - - -If we use [rotate_sweep()](https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#functionmodule-rotate_sweep) to sweep that path around the y-axis we have a solid vase-shaped object. Here we're using both $fn and the splinesteps argument to produce a smoother object. - - -```openscad -include -include -$fn = 72; - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -closed = bezpath_close_to_axis(bez, axis = "Y"); -path = bezpath_curve(closed, splinesteps = 32); -rotate_sweep(path,360); -``` -![Figure 7](images/Béziers_for_Beginners_7.png) - -Instead of closing the path all the way to the y-axis, we can use [bezpath_offset()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_offset) to duplicate the path 5 units to the left, and close the two paths at the top and bottom. Note that bezpath_offset takes an x,y pair as an offset value. - -```openscad -include -include -$fn = 72; - -bez = [[20,0], [60,40], [-20,50], [25,80]]; -closed = bezpath_offset([-5,0], bez); -debug_bezier(closed); - -``` -![Figure 8](images/Béziers_for_Beginners_8.png) - -Note that [bezpath_offset()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_offset) does not ensure a uniform wall thickness. For a constant-width wall we need to offset the path along the normals. This we can do using [offset()](https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#function-offset), but we must first convert the Bézier to an OpenSCAD path, then reverse the offset path to create a closed path. -You can see the difference between the two methods here, with [bezpath_offset()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_offset) in blue, and [offset()](https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#function-offset) in red. - -```openscad -include -include -$fn = 72; - -bez = [[40,0], [110,40], [-60,50], [45,80]]; - -bez2 = bezpath_offset([5,0], bez); -closed= bezpath_curve(bez2, splinesteps = 32); -color("blue") stroke(closed); - -path2 = bezier_curve(bez, splinesteps = 32); -closed2 = concat(path2,reverse(offset(path2,delta=5)),[bez[0]]); -right(30) color("red") stroke(closed2); - -``` -![Figure 9](images/Béziers_for_Beginners_9.png) - - -Sweeping a Bézier path offset using either method around the y-axis gives us a shape with an open interior. However, as this cross section shows, our new path does not close the bottom of the vase. - -```openscad -include -include - -$fn = 72; - -bez = [[15,0], [60,40], [-25,50], [25,80]]; -closed = bezpath_offset([5,0], bez); -path = bezpath_curve(closed, splinesteps = 32); -back_half(s = 200) rotate_sweep(path,360); -``` -![Figure 10](images/Béziers_for_Beginners_10.png) - -We'll use a cylinder with a height of 5 for the floor of our vase. At the bottom of the vase the radius of the hole is bez[0].x but we need to find the inside radius at y = 5. The function [bezier_line_intersection()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezier_line_intersection) will return a list of u-values where a given line intersects our Bézier curve. The function [bezier_points()](https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad#function-bezpath_points) will convert that list of u-values to a list of x,y coordinates. Drawing a line at y = 5 gives us the single-element list [[20.1072,5]]. - -```openscad -include -include - - -bez = [[15,0], [60,40], [-25,50], [25,80]]; -debug_bezier(bez); -line = [[0,5], [30,5]]; -color("red") stroke(line); -u = bezier_line_intersection(bez,line); -echo(bezier_points(bez,u)); // [[20.1072,5]] - -``` -![Figure 11](images/Béziers_for_Beginners_11.png) - -That means a cyl() with a height of 5, a bottom radius of bez[0].x and a top radius of 20.1072 will just fit our vase. - - -```openscad -include -include - -$fn = 72; - -bez = [[15,0], [60,40], [-25,50], [25,80]]; -closed = bezpath_offset([5,0], bez); -path = bezpath_curve(closed, splinesteps = 32); -back_half(s = 200) rotate_sweep(path,360); -color("red") cyl(h = 5, r1 = bez[0].x, r2 = 20.1072, anchor = BOT); -``` -![Figure 12](images/Béziers_for_Beginners_12.png) - - -Keep in mind the fact that **$fn** controls the "roundness" of OpenSCAD objects other than Bézier curves. Bézier's smoothness is controlled by the **splinesteps** argument. - -```openscad -include -include - -$fn = 72; - -bez = [[15,0], [40,40], [-20,50], [20,80]]; -closed = bezpath_offset([2,0], bez); -path = bezpath_curve(closed, splinesteps = 64); - -rotate_sweep(path,360, $fn = 72); -right(60) rotate_sweep(path,360, $fn = 6); -right(120) rotate_sweep(path,360, $fn = 4); -``` -![Figure 13](images/Béziers_for_Beginners_13.png) -