Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to give thickness to a bezier patch? #1453

Closed
dan-p3rry opened this issue Jul 17, 2024 · 3 comments · Fixed by #1458
Closed

how to give thickness to a bezier patch? #1453

dan-p3rry opened this issue Jul 17, 2024 · 3 comments · Fixed by #1458

Comments

@dan-p3rry
Copy link

I'm modeling a sail, using bezier code in BOSL2. I can create the shape I want with zero thickness, but I haven't found a way to give the shape the required thickness.

`include <BOSL2/std.scad>
include <BOSL2/beziers.scad>
sail_width = 80;
sail_length = 0.7*sail_width;
center_z = 20;
edge_z = 8;

patch = [
    [[0, 0.5*sail_width, 0], [0.33*sail_length,  0.36*sail_width, edge_z], 
            [0.67*sail_length, 0.15*sail_width, edge_z], [sail_length, 0, 0]],
    [[0, 0, 0], [0.33*sail_length, 0, center_z], 
            [0.67*sail_length, 0, center_z-5], [sail_length, 0, 0]],
    [[0, -0.5*sail_width, 0], [0.33*sail_length, -0.36*sail_width, edge_z], 
            [0.67*sail_length, -0.15*sail_width, edge_z], [sail_length, 0, 0]]
];
//debug_bezier_patches(patches=[patch], size=1, showcps=false);

`

The following code is my inelegant attempt and barely satisfactory (because I'm not getting a uniform thickness), so I'm asking for help. Thanks!
vnf = bezier_vnf([ patch, up(1, patch), ]); difference() { hull() vnf_polyhedron(vnf); translate([0, 0, -0.75]) scale([1.01, 1.01, 1.00]) hull() vnf_polyhedron(vnf); }

@adrianVmariano
Copy link
Collaborator

function bezier_sheet(patch, thickness, splinesteps=16, style="default") =
  assert(is_bezier_patch(patch))
  assert(all_nonzero([thickness]), "thickness must be nonzero")
  let(
        splinesteps = force_list(splinesteps,2),
        uvals = lerpn(0,1,splinesteps.x+1),
        vvals = lerpn(1,0,splinesteps.y+1),
        pts = bezier_patch_points(patch, uvals, vvals),
        normals = bezier_patch_normals(patch, uvals, vvals),
        dummy=assert(is_matrix(flatten(normals)),"Bezier patch has degenerate normals"),
        offset = pts + thickness*normals,
        allpoints = [for(i=idx(pts)) concat(pts[i], reverse(offset[i]))],
        vnf = vnf_vertex_array(allpoints, col_wrap=true, caps=true, style=style)        
  )
  thickness<0 ? vnf_reverse_faces(vnf) : vnf;

Try the above. I'm not sure what to call it. Any suggestions?

@dan-p3rry
Copy link
Author

Thanks! I had to do some debugging and repair of my patch, then it worked perfectly. The bezier documentation is very good, too, helped me to debug the issue on my own.
My suggestion for the function name is bezier_patch_extrude().

@adrianVmariano
Copy link
Collaborator

My concern about using "extrude" or "sweep" in the name is that this function can only make "thin" or "short" extrusions. If you set the thickness to a large value and there is any negative curvature, the result will be invalid.

@adrianVmariano adrianVmariano linked a pull request Jul 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants