I have closed planar polyline curves, some with sharp angles and i want them to be sorted or shattered based on the relative angles for example, anything greater than 200 degrees or less than 160, any ideas or solutions for grasshopper?
(Also, i am fully aware there are at least 3 different ways that are probably quicker and achieve the same result in rhino and grasshopper but im curious if there is a way to do it using this specific method of finding relative angles)
it’s Sunday morning.. there is probably a simpler way, but this should work:
my path management requires you to switch between evaluating a single or multiple curves, so make sure to use the boolean toggle at the stream filter accordingly.
@martinsiegrist@Kayne_Li I mean, if we are going to go the Kangaroo route, there is SplitAtCorners one panel over in Utilites that splits a polyline at vertices that have an interior angle below a threshold value.
None of these option do what the OP requested, which is to split a polygon based on a domain of exterior angles, but this might be more a case of “do as a mean” than “do as I say.”
Using Angle, you’re going to be measuring the the smaller or larger of the two angles which may or may not be the exterior angle of the closed polyline. You will have have to switch between the outputs A and R depending on whether the corner is concave or convex, which you can do using any of the multitude of methods explored here. (You might have seen this link already. I deleted my previous post because I was unsure of myself.)
You could also Evaluate Curve and apply a threshold to the incoming/outgoing angle it gives. I would remap curve domain to the vertice count, so that evaluating the curve becomes easy; just the whole number parameters of the curve. Remapping domain also makes shattering easy. Evaluate your mask against bool “true” with Member Index and the indices are your shatter params.
Less talk, more do. This is what that would look like:
Remapping the domain wasn’t enough. You need to rebuild from the vertices. I imagine this is exactly what SplitAtCorners is, only here you can dig into the conditional and do things like target domains with closed or open bounds.
Hello,
a small integration (I’m working in Rhino7, I don’t know if in Rhino8 it works differently. in that case sorry and please let me know): after exploding the curve and making pairs of consecutives segments, Angle result depends on the plane input:
if you don’t specify any input plane, it always measure the smalller angel between the vectors (blue)
if you specify a plane, it measure the angle of the vectors projected on plane, from the first vector to the second, going counterclockwise on the plane (yellow, with XY plane in this example)
your script acts like using Angle without a plane: if you check closely you are still measuring the smallest angle without relationship with being concave or convex.
To correctly measure the internal angle of the polyline, you need to check the polyline orientation, provide the correct plane in Angle component, and play with the vectors (in the example below, polyline is counterclockwise in XY, plane is XY and angle is between (i+1) and reverse(i) )
No, that’s not… I am a little confused whether you addressing @dk2079 or me, because I do not use Angle in my script at all.
The behavior you describe is correct, so as @dk2079 has used Angle (without a plane) it will measure the smaller and larger angles with the outputs A and R respectively. Evaluate Curve, however, does not find either the smallest/largest angle or the angle in the counter-clockwise direction of the plane. It measures the delta vector at a parameter, meaning the difference of the incoming and outgoing vectors as a positive value. That value can be left or right handed, and it can be smaller than or larger than 180 degrees.
That discrepancy is outlined here (Evaluate Curve is placed on the wrong side of the image as I was drawing over an existing one). The difference between Angle andEvaluate Curve is what uniquely positions Angle to ascertain convex / concave corners unlike Evaluate Curve.
The delta vector angle that Evaluate Curve uses seems to be the exact angle that is SplitAtCorners uses for thresholding. At least in testing SplitAtCorners against my script, I got the same results. It is also the more useful angle measurement here as it measures how much “turn” there is in the corner, regardless of direction.
Edit upon edit upon edit. What is wrong with me today?
I’m addressing both Evaluate Curve from @Volker_Rakow’s script measure the angle the same way it’s defined with Angle (without plane input and taking A output) from @dk2079’s script: the smallest angle between incoming and outcoming vectors, always smaller than 180 degrees
It’s true, I did not realize that the apparent task at hand was to only get the outside counterclockwise angles.
So what is needed are basically signed angles.
And it is true that it is possible to get that from ANGLE with plane. thanks @Fabio_Franchetti
Still resisting the plugIn temptation (froGH has a signed angle component) I looked at how to calculate this vanilla. (not realizing providing a plane works too)
It is a little series of vector calculations (green blob) and the the signed angles still need to be formatted into 0<360 (pink blob)
and the it is easy to establish whatever logic to filter some domain of angles.
I shattered the curves at the angle domains and assigned them a colour gradient in relation to their length, so going counter clockwise (forgot to mention we need to align all closed input curves with giude curve to counter clockwise) you find the annotation dot and then the segment in the same colour.
(if we would flip the curve clockwise we get interor angles..)