Posts: 3

Threads: 1

Joined: Sep 2022

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.

Posts: 1,625

Threads: 73

Joined: Jun 2017

Hi

There are two ways I am thinking of:

- 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.

- 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.

Posts: 3

Threads: 1

Joined: Sep 2022

10-02-2022, 11:17 AM
(This post was last modified: 10-02-2022, 11:37 AM by Einherj.)
(10-01-2022, 08:09 AM)_Aka_ Wrote: Hi

There are two ways I am thinking of:

- 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.

- 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?

Posts: 1,625

Threads: 73

Joined: Jun 2017

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.

Posts: 3

Threads: 1

Joined: Sep 2022

Thank you very much for your answers.

I was about to implement the De Casteljau's algorithm myself.

Posts: 1,625

Threads: 73

Joined: Jun 2017

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.