# Clculating the intersection point of two splines

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/09/2011 at 16:38, xxxxxxxx wrote:

I was have been scouring the interwebs for information on finding the intersection point of two splines, but it all seems to rely on what language you are using and what software you are using.
anyone have any good resources or info on how to accomplish this task from scratch? or perhaps there is something inside the sdk i am overlooking...

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/09/2011 at 12:21, xxxxxxxx wrote:

I think i finally found something by searching for the term "line line interseection" which should work.

http://mathworld.wolfram.com/Line-LineIntersection.html

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/09/2011 at 14:32, xxxxxxxx wrote:

after a bit of work i got it working!

``````def FindIntersect(p1,p2,p3,p4) :
from c4d import Vector as v
x1 = p1.x
x2 = p2.x
x3 = p3.x
x4 = p4.x
y1 = p1.z
y2 = p2.z
y3 = p3.z
y4 = p4.z
ipx1_1 = (x1*y2-y1*x2)*(x3-x4)
ipx1_2 = (x1-x2)*(x3*y4-y3*x4)
ipx1 = (ipx1_1-ipx1_2)
ipx2_1 = (x1-x2)*(y3-y4)
ipx2_2 = (y1-y2)*(x3-x4)
ipx2 = (ipx2_1-ipx2_2)
if ipx2 != 0:
ipx = interpntX = ipx1/ipx2
else:
ipx = 0
ipy1_1 = (x1*y2-y1*x2)*(y3-y4)
ipy1_2 = (y1-y2)*(x3*y4-y3*x4)
ipy1 = (ipy1_1-ipy1_2)
ipy2_1 = (x1-x2)*(y3-y4)
ipy2_2 = (y1-y2)*(x3-x4)
ipy2 = (ipy2_1-ipy2_2)
if ipy2 != 0:

ipy = interpntY = ipy1/ipy2
else:
ipy = 0
intersection = v(ipx,0,ipy)
return intersection
``````

basically, you supply four points and it will find their intersection point, even if its floating way out in space! math is fun 