Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Intersection of two curvy splines
#1
Is there a method to find the intersection of two curvy splines? (red circle in image)
I need to find the position where two Curvy splines intersect to merge the splines at that position.
   
Reply
#2
Hi
There are two ways I am thinking of:
  1. The elegant one, but difficult one: look up for "X splines intersection" with X being the type of splines you are using. You should find the mathematical equation to find such intersection. Implement it, then apply it on the splines for which you want to find an intersection.
  2. The brute force one: take one of the splines (A), and go through its points (for example sample 1000 point on it) and for each one find the nearest point on the other spline (B) (see CurvySpline.GetNearestPoint). Calculate the distance between both points. If you find a point with a distance smaller than a threshold you would specify, then it means that there might be an intersection nearby. You can try again with another set of points around that found point, until you find a distance small enough to be considered equivalent to 0.
I hope this helped
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
(10-01-2022, 08:09 AM)_Aka_ Wrote: Hi
There are two ways I am thinking of:
  1. The elegant one, but difficult one: look up for "X splines intersection" with X being the type of splines you are using. You should find the mathematical equation to find such intersection. Implement it, then apply it on the splines for which you want to find an intersection.
  2. The brute force one: take one of the splines (A), and go through its points (for example sample 1000 point on it) and for each one find the nearest point on the other spline (B) (see CurvySpline.GetNearestPoint). Calculate the distance between both points. If you find a point with a distance smaller than a threshold you would specify, then it means that there might be an intersection nearby. You can try again with another set of points around that found point, until you find a distance small enough to be considered equivalent to 0.
I hope this helped
Have a nice day

Thank you.
I think I will go with Bezier curves and try to implement the Bezier clipping algorithm.

I'm guessing there is a curve splitting algorithm in Curvy somewhere, since you can add control points in the middle. Where is it? How is it implemented?

Have you thought of implementing intersection algorithms into the Curvy package in the future?
Reply
#4
Hi
There are no short term plans for intersection algorithms, but I don't exclude the idea of adding them later in the package.


The subdivision is implemented in the CurvySpline.Subdivide method. Here is a comment from it:


Code:
//Based on De Casteljau's algorithm. The following is it's special case implementation for a subdivision at the middle of a spline segment.

//Here is a picture explaining things: https://jeremykun.files.wordpress.com/2013/05/subdivision.png from https://jeremykun.com/2013/05/11/bezier-curves-and-picasso/

I hope this comment will be helpful for you.

Did I answer all your questions?
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
Thank you very much for your answers.
I was about to implement the De Casteljau's algorithm myself.
Reply
#6
You are welcome.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 3 Yesterday, 07:55 PM
Last Post: _Aka_
  Using Unity's SplineContainer in Curvy Splines dlees9191 3 12 02-26-2024, 09:49 AM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_
  Finding relative position across connected splines DekoGames 1 8 02-05-2024, 10:11 PM
Last Post: _Aka_

Forum Jump: