-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Feature: convert sharp corners to round corners #515
Comments
No, there is no such feature for the time being. It would make for a great addition and/or plug-in though! |
Thx for reply! |
We can keep his open for records. It's a good feature request. |
Hi guys, that really sounds like a cool feature to implement. Furthermore this excellent Stack Overflow post describes the geometry of the problem at hand very well. I just have a concrete implementation question at hand: should I simply add a "rounder_corners" method to the LineCollection class? Effectively this method would create out of two LineStrings two shortened LineStrings and one LinearRing. |
@dev-89 Thanks for reaching out! I wouldn't cut/merge paths with this feature (where "path", in vpype, is always a line string – technically a numpy array of complex – where the last point might be identical to the first if it's closes). So the function would take a path, and return another path with its angle rounded (based on a radius and some quantisation control parameter). I would first create a function to operate on a single path (typically in |
Right, I think I understand now. Will get coding in the coming days and any further questions we can discuss over the PR. |
There's other more simple methods of doing this. You're focusing on just replacing the corner with an arc. But really you can just segmentize the segments. Apply smooth (#216) repeatedly. Then simplify the segments.
And most of these things are already there and can be applied pretty easy. We only really need as many segments as we're applying the smooth. So if we apply smooth 10 times only the 10 closest points could be affected. You can also segment just part of a line nearest to the sharp corner, or some distance along that line (sort of radius)). |
Keep in mind a strong point of this proposed algorithm is the use of numpy. You can apply this to line segments really easily with the code you already have without bunch of other libraries. The
midpoint = (line[2:] + line[:-2]) / 2.0
middlepoint = line[1:-1]
line[1:-1] = amount * (midpoint - middlepoint) + middlepoint) The first = line[2:]
mid = line[1:-1]
last = line[:-2]
x1 = np.real(first)
y1 = np.real(first)
x2 = np.real(mid)
y2 = np.real(mid)
x3 = x2
y3 = y2
x4 = np.real(last)
y4 = np.real(last)
denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1) Then delete the points where So all straight forward with the code you have currently. |
When I use a knife to cut, the sharp corners are not handled very well,
easy to lift,
The text was updated successfully, but these errors were encountered: