How is the scaling for Path3D getDistanceAt or getPointAt calculated?

Is this scaled by length to get to the range 0-1.0? I’m trying to implement a radius function in an extrusion that uses another Path3D to calculate the radius. The radius function has an index and a distance parameter, one or both of which I need to use to map into the other path to get a radius. My best current thought is to scale the distance value by the extrusion path length to get a value in the range 0-1, then use that to getPointAt(v) in the other path to get a corresponding point. In the picture below, imagine the extrusion axis to be the green Y axis, and the white hermite curve to the right to be the radius outline. So, as I go from A to B on the Y axis, I need to pick a point on the hermite curve to get the radius - in this case the x-coordinate. It’s simple when everything is aligned on the axes, but I need a generic and hopefully simple way for arbitrary paths. BTW, just casting a ray along the normal could return two points, so that doesn’t work

@lowclouds you are more likely to get a quicker and relevant answer if you include a playground - rather than/as well - as an image.

For example from you question I would suggest you use a custom extrusion rather than just an extrusion, however I can not see if you are already doing this.

Also if you were to add a playground we could see how you were going about it and if we saw a solution make the edits.

When extruding a circle with radius = 1
Mapping from x values of Path3D to Extrusion Path using distance d

for 0 ≤ d ≤ 1

extrusion shape scale at (d) = getPointAt(d).x

1 Like

Thanks, JohnK, I’m working on a possible solution, which I’ll share when I have it working. I am using customExtrusion. The algorithm is the following for a custom extrusion from p0 to p1, and Path3D radius shape, rpath;
construct straight Path3D from p0 to p1 = basepath.
clength = extrusion path length (from path3d of extrusion)
in custom extrusion radius function, use clength to scale distance d parameter,
t = d/clength
rv = basepath.getPointAt(t)
ru = rpath.getPointAt(t)
radius = |rv - ru|

In the drawing above p0 would be at (0,0,0) and p1 on the y axis at same height as the hermite spline. The actual extrusion path may wander around between p0 and p1

Ok, here’s my first attempt at this - it’s almost, but not quite what I was hoping for.

cc @Cedric

ok, based on this animation, I think I need to project directly to the basepath line from the spline to get a better radius.

Ok, this is what I needed; slightly different than what I initially thought I had to do. The idea is to recompute the extrusion path based on the spline path so you can get the path to go backwards. Here’s a solution for straight extrusion paths. need to work on arbitrary extrusion paths.

A slightly simplified version

For a vertical extrusion line only this will match the contour of the extruded mesh to that of the spline.

Since this methods forces the y value on the basepath it cannot be used for arbritary basepaths.

For example if we take a 45deg line for the basepath we can see that there is not a 1 to 1 correspondence between the y values of the basepath and the spline

We can obtain a 1 to 1 correspondence between the fractional distances along the basepath and the spline but although the spline will drive the radius value the contour of the extruded mesh will no longer match that of the spline.

You can now however make your basepath arbritary

1 Like

Thanks again! I rethought the reconstruction of the straight basepath section and realized what I needed to compute were the t values along the straight section, which are fairly straightforward. Using those, I can then reconstruct an arbitrary path. First playground is with straight extrusion path at an angle. Second is using a spline path. Obviously, things can go wrong if the path is too tight for given radii.

using curved path

1 Like

My quick thoughts:
I would calculate the distance between the 2 curves for a same value of s/step. this would give me the circle radius.
And I would compute the derivative of the extrusion curve to get the normal.
But, depending on the shape of the curve, s is not linear with the length of the curve. In other words, for the same s value, it would return a different length proportion on each curve.
Not sure hoz big it will impact mesh generation quality. But I would try to compute each curve length as a first step to be sure length is proportion for each step.

1 Like

The reference implementation I’m trying to reproduce calculates the radii as the distance between the radius curve and a straight line between the end points of the extrusion path. The radius curve spline control points are the endpoints of the extrusion curve offset by the given radii at the endpoints.
If the extrusion path length is much longer than the straight-line path then problems crop up. There are also issues when the extrusion path curvature is wild. The primary visual effect is that the tangents at the endpoints can be different than the radius curve tangents. I haven’t quite figured how to adjust this well, but you may have a good idea about trying to adjust the t values. The Path3D object does a lot of work for you in these respects.