-
Notifications
You must be signed in to change notification settings - Fork 73
Request: Splines? #136
Comments
I'm curious what particular limitations of cadquery are you facing? |
Splines are possible. Exactly duplicating the CadQuery API is not possible, because CadQuery and Curv use quite different internal representations. Curv is a volumetric (V-rep) solid-modelling tool, meaning that the fundamental primitives are solid objects. CadQuery uses boundary representation (B-rep), meaning that the primitives describe the boundaries of solid objects. So it changes the set of primitives that are available, and it changes the way you design a model using those primitives. We already have an The CadQuery The original paper describing the math behind Curv (signed distance fields or SDF) describes a spline primitive. See |
Thank you very much @doug-moen ! Luckily I have looked into the math behind splines to implement my own spline in OpenSCAD:
Well, "spline", it's for a 4-point bezier curve. I'm curious, how would you model something like this (an ergonomic controller arm)?
In particular creating complex curved surfaces is not CadQuery's forté. While I can get pretty far using splines, arcs, and fillet, it gets increasingly hard for CadQuery to accept what I'm asking of it (it will simply say "cannot do B-rep operation" or something like that). After literally playing with Curv for 1 hour last night and learning just from looking at examples and the docs I'm very impressed with how easy it was to pick up. It may have to do with how I have experience with functional PLs and OpenSCAD though (the latter I doubt because I feel the mental model is different compared to it). |
OpenSCAD uses boundary representation, which is different from Curv. Your OpenSCAD bezier4 function converts a spline into a collection of line segments, which you could feed into the Curv Here's the code for
The The polygon code is magic, I didn't invent it, I just copied it from shadertoy.com and transliterated the code into Curv. The spline code needed for Curv will be magic in a similar way. I hope there is some SDF spline code on the internet that can be adopted. |
Excellent, I will look for an SDF spline then! Thank you for all the excellent help Doug. Your project is crazy awesome. Edit: I'll leave this issue open until someone or me has implemented it. |
Hi, I'm not sure if this is the right place to mention this. I had a look at the current code for sweeping along Bezier curves. I am also aware of a 2D analytic SDF for quadratic Beziers: https://www.shadertoy.com/view/MlKcDD which seems like it could be mentioned here. |
Thank @theohonohan - I've tried such SDFs but they don't work well for the reason of needing to make a closed shape. |
It seems a few smart people have come along and figured out some potential SDFs for this! https://www.shadertoy.com/view/3dtBR4 |
@doug-moen posted some code which referred to Inigo Quilez. He founded ShaderToy and his site is a good place to start: I am not sure what you mean by "the reason of needing to make a closed shape". It's hard not to end up with a closed contour when dealing with SDFs. |
@theohonohan you can't just arbitrarily combine SDFs. There are "proper SDFs" that are necessary for further manipulations. An example is the offset manipulation. If you don't have a proper SDF, this will fail. That example is not using bezier curves. I have studied those exact materials over a year ago and they were not sufficient to create proper SDFs for arbitrary closed shapes. |
RIght, the third link does discuss the difficulty of making a valid SDF. But the link https://www.shadertoy.com/view/3dtBR4 which you posted just uses min() to intersect SDFs, which is what gave me the idea that you were OK with approximate results. The problem is not that the resulting shape isn't "closed", though. |
Here's another one. 3 Bezier splines joined into a closed 2D shape. |
Is your feature request related to a problem? Please describe.
I'd like to be able to specify a spline. Right now I'm trying to create an ergonomic controller, and I'm hitting limitations in CadQuery, which have led me here to Curv.
Describe the solution you'd like
Add a new function:
spline list_of_points list_of_tangents
. That's it!Describe alternatives you've considered
None
Additional context
It may be necessary to add other sketching functions like hLine, vLine, ellipse, etc, like from CadQuery, to create enclosed shapes. https://cadquery.readthedocs.io/en/latest/apireference.html#d-operations
This is the design so far but it's lacking, as I want everything to be smooth:
In the meantime I've been recreating a soroban design in curv to compare it to cadquery and I'm really loving what I'm seeing!
The text was updated successfully, but these errors were encountered: