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
Exclamation Stack overflow when editing prefab containing splines rhys_vdw 4 10 11-30-2022, 11:38 AM
Last Post: _Aka_
Question How to modify Example 12 to work bi-directionally and more than 2 connected splines Mambosa 3 5 11-29-2022, 06:59 PM
Last Post: _Aka_
Information Curvy 8.3.0 is live _Aka_ 0 5 10-27-2022, 10:54 AM
Last Post: _Aka_
  Curvy for Playmaker thorntonp72@gmail.com 1 4 10-23-2022, 11:41 AM
Last Post: _Aka_

Forum Jump: