Re: [curv] add chamfered distance fields for the primitive shapes

8 views
Skip to first unread message

Doug Moen

unread,
Mar 19, 2021, 6:03:38 PM3/19/21
to Curv
A more flexible design is to add an 'edge=<blend>' argument to all of the primitives with sharp edges. The blend argument can be `smooth r`, `chamfer r`, `stairs [r,n]`, `column [r,n]`, or any user defined blend operator. A new blend operator called `sharp`, which applies no effects to the edges, is introduced to act as the default `edge` value.

On Fri, Mar 19, 2021, at 4:30 PM, Angelo Tartanian wrote:
It's great to be able to chamfer boolean operations between shapes, but something missing is the ability to generate chamfered shaped initially.

```
let
chamferedrect = size -> chamfer_r -> 
    let
    r = size / 2 - chamfer_r;
    in
    make_shape {
    dist[x,y,z,t] =
    if (abs(x) > abs(r@X) && abs(y) > abs(r@Y))
    (abs(x)-abs(r@X)+abs(y)-abs(r@Y)) - chamfer_r
else
(max(abs([x,y]) - (r + chamfer_r)));
    bbox = [[-r@X,-r@Y,0],[r@X,r@Y,0]];
            is_2d = true;
    }
;

in
show_dist (chamferedrect (2, 3) .5)
```

This could be added as a `.chamfered` alternate distance field like `.exact` or `.mitred` and could be added to all of the primitives with sharp edges. since it would be an addition it should not break any backwards compatibility.


--
You received this message because you are subscribed to the Google Groups "Curv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to curv+uns...@googlegroups.com.

Angelo Tartanian

unread,
Mar 20, 2021, 11:25:32 AM3/20/21
to Curv
how would that work? I'll admit I'm new to SDF modeling but I've not seen any way to specifically modify "edges" or any other "surface" feature of a geometry

Angelo Tartanian

unread,
Mar 20, 2021, 11:29:30 AM3/20/21
to Curv

If that were possible, it would mean we should be able to have just a chamfer(shape) function, right?

Doug Moen

unread,
Mar 20, 2021, 12:07:35 PM3/20/21
to Curv
What I have in mind is to add an 'edge=<blend>' argument to primitives with sharp edges. For example, instead of 'cube 10', write 'cube{d: 10, edge: chamfer 1.5}'.

A blending operator is a record with 5 fields called union, intersection, difference, bmin and bmax. See lib/curv/lib/blend.curv for details.
The 'sharp' operator would be defined as follows:
  sharp = { union: union, intersection: intersection, difference: difference, bmin: min, bmax: max }

Another thing to note that that the union of two shapes is the 'min' of the distance fields, and the intersection of two shapes is the 'max' of the distance fields. All of the Curv blending operators work by substituting customized versions of 'max' and 'min'.

Furthermore, in the primitives that have sharp edges, it is normally the case that the sharp edges are created using union, intersection, max and min. That's particularly true for the 'mitred' versions of the primitives. I'm less sure that my trick will work for the 'exact' versions, which are trickier to implement.

So, my idea is to add these 'edge=' parameters, defaulting to 'sharp', to at least the mitred versions of edged primitives. Within the distance function, substitute edge.bmax for max, and edge.bmin for min. Or, if union and intersection are being used instead of a distance function, then substitute edge.union and edge.intersection.

I haven't tried this, but it should mostly work. It would be interesting to see where this strategy fails, and see if we can work out alternatives.

Doug Moen.
Reply all
Reply to author
Forward
0 new messages