Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find curve corner points using JTS or NTS?

Tags:

java

c#

.net

jts

I have a curve (say JTS edge):

enter image description here

How to find all curve direction change points that surpasses given angle using JTS (Java) or NTS (C#):

enter image description here

like image 358
DuckQueen Avatar asked May 30 '18 21:05

DuckQueen


1 Answers

I did some research and made some tests on JTS, and the best way I found is:

  • Create polygons and use the function union
  • Then iterate over the Coordinates, and create a sub-array on each "hard angle" (negative scalar product) and when the sum of angle reaches 180 (don't take the last angle to avoid non-function issues)
  • Then I change the base to an orthonormal base with x(firstElemOfSubArray, lastElemOfSubArray) by computing the base-changing matrix, and I then recompute the sub-array in a new coordinate system
  • I then create a function using org.apache.commons.math3.analysis.interpolation.SplineInterpolator to interpolate the function of the course, and then I get the derivative and search the extrema (don't take elements with an ordinate that is too low). With its absysse you can find which point is an inflexion point
  • So the point you search for are first elements of each sub array, and its inflections points (if there are any)
like image 163
Arnault Le Prévost-Corvellec Avatar answered Nov 17 '22 12:11

Arnault Le Prévost-Corvellec