jbuckmccready / CavalierContours

2D polyline library for offsetting, combining, etc.
MIT License
421 stars 79 forks source link

Have any plan to add B-Spline offset? #19

Closed YggSky closed 4 years ago

jbuckmccready commented 4 years ago

I have no plans currently to add B-Spline support. I don't know what your use case is, but there are probably algorithms/apps/libraries to covert B splines into line + arc approximated paths that could then be fed into this library, and then the output could be used as is, or if needed there are likely algorithms/apps/libraries for approximating lines + arcs into B splines. In the future I might look into adding those approximation algorithms but currently I don't have any plans to do so.

If you're thinking of offsetting B Spline surfaces (not 2D paths) in 3D then the algorithm in this library is not applicable at all, it's entirely built up around offsetting paths in 2D space (finding distances, intersections, spatial indexing, etc. all works in 2D space and wouldn't work on a 3D surface).

YggSky commented 4 years ago

I have no plans currently to add B-Spline support. I don't know what your use case is, but there are probably algorithms/apps/libraries to covert B splines into line + arc approximated paths that could then be fed into this library, and then the output could be used as is, or if needed there are likely algorithms/apps/libraries for approximating lines + arcs into B splines. In the future I might look into adding those approximation algorithms but currently I don't have any plans to do so.

If you're thinking of offsetting B Spline surfaces (not 2D paths) in 3D then the algorithm in this library is not applicable at all, it's entirely built up around offsetting paths in 2D space (finding distances, intersections, spatial indexing, etc. all works in 2D space and wouldn't work on a 3D surface).

thanks.by the way , [1] Liu, X.-Z., Yong, J.-H., Zheng, G.-Q., & Sun, J.-G. (2007). An offset algorithm for polyline curves. Computers in Industry, 58(3), 240–254. doi:10.1016/j.compind.2006.06.002 I search it on google ,but can't find direct to read,all have special condition can do, of course I meet not . how do you arrive literature and read,have some simple way?

jbuckmccready commented 4 years ago

I usually end up using sci-hub for pay walled journals. That paper is also just hosted in pdf form here.

YggSky commented 4 years ago

I usually end up using sci-hub for pay walled journals. That paper is also just hosted in pdf form here.

thanks a lot.

YggSky commented 4 years ago

createFastApproxBoundingBox this function caculate arc Approx AABB.

double offsX = b (v2.y() - v1.y()) / double(2); double offsY = -b (v2.x() - v1.x()) / double(2);

I can't clear about it,i konw AABB,but can't understand,how could it can always equal to or bigger than the true bounding box.

jbuckmccready commented 4 years ago

Check out this page to understand the relationship between the arc chord, bulge, and sagitta. Basically it's moving the arc chord line out along the sagitta towards the outside of the arc and then computing the min/max of all the end points. If you get the CavalierContoursDev project running you can visualize it by viewing the spatial index bounding boxes on an arc segment.

jbuckmccready commented 4 years ago

Here's a quick sketch I made to visualize it: image

The approximate AABB is found by just finding the min and max X and Y components of the P1, P2, P3, P4. Hope that helps explain it.

YggSky commented 4 years ago

Here's a quick sketch I made to visualize it: image

The approximate AABB is found by just finding the min and max X and Y components of the P1, P2, P3, P4. Hope that helps explain it.

it very clear,I see,thanks.