1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-25 23:46:32 +02:00

renamed parameters

This commit is contained in:
Justin Lin
2017-04-10 10:11:31 +08:00
parent 915cd36f7f
commit 98c451fafb
2 changed files with 59 additions and 38 deletions

View File

@@ -12,8 +12,8 @@
* *
**/ **/
function _combi(r, n) = function _combi(n, k) =
n == 0 ? 1 : (_combi(r, n - 1) * (r - n + 1) / n); k == 0 ? 1 : (_combi(n, k - 1) * (n - k + 1) / k);
function bezier_curve_coordinate(t, pn, n, i = 0) = function bezier_curve_coordinate(t, pn, n, i = 0) =
i == n + 1 ? 0 : i == n + 1 ? 0 :

View File

@@ -1,4 +1,6 @@
include <hull_polyline3d.scad>;
include <line3d.scad>;
include <polyline3d.scad>;
include <bezier_curve.scad>; include <bezier_curve.scad>;
include <bezier_surface.scad>; include <bezier_surface.scad>;
include <function_grapher.scad>; include <function_grapher.scad>;
@@ -14,19 +16,26 @@ ctrl_pts = [
]; ];
g = bezier_surface(t_step, ctrl_pts); g = bezier_surface(t_step, ctrl_pts);
function_grapher(g, thickness); color("yellow") function_grapher(g, thickness);
width = 2;
demo = "YES"; demo = "YES";
// demo ani = "YES";
if(demo == "YES") { if(demo == "YES") {
width = 2; width = 2;
r = 3; r = 3;
pts = [ pts = [
for(i = [0:len(ctrl_pts) - 1]) for(i = [0:len(ctrl_pts) - 1])
bezier_curve(t_step, ctrl_pts[i]) bezier_curve(t_step, ctrl_pts[i])
]; ];
if(ani == "YES") {
// first bezier curve // first bezier curve
for(i = [0:len(ctrl_pts) - 1]) { for(i = [0:len(ctrl_pts) - 1]) {
color("green") union() { color("green") union() {
@@ -36,14 +45,14 @@ if(demo == "YES") {
} }
for(j = [0:len(ctrl_pts[i]) - 1]) { for(j = [0:len(ctrl_pts[i]) - 1]) {
hull_polyline3d( polyline3d(
ctrl_pts[i] ctrl_pts[i]
, width); , width);
} }
} }
color("red") color("red")
hull_polyline3d( polyline3d(
bezier_curve(t_step, ctrl_pts[i]), width bezier_curve(t_step, ctrl_pts[i]), width
); );
} }
@@ -58,9 +67,21 @@ if(demo == "YES") {
translate(pt) translate(pt)
sphere(r = r); sphere(r = r);
} }
hull_polyline3d(ctrl_pts2, width); polyline3d(ctrl_pts2, width);
} }
color("black") color("black")
hull_polyline3d(g[$t * step], width); polyline3d(g[$t * step], width);
} else {
// first bezier curve
for(i = [0:len(ctrl_pts) - 1]) {
color("green") union() {
for(j = [0:len(ctrl_pts[i]) - 1]) {
translate(ctrl_pts[i][j])
sphere(r = r);
}
}
}
color("green") function_grapher(ctrl_pts, width, style = "LINES");
}
} }