Bezier Intersections

BlitzPlus Forums/BlitzPlus Programming/Bezier Intersections

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

sorry but the code=1856 its not a real solution of my problem, its too slow for my purposes and its not exact enough.

but

i think that's easier than i thought.

the equation of a Bezier3 is:

Bzx#=x1*(1-t)^3 + 3*vx1*(1-t)^2*t + 3*vx2*(1-t)*t^2 + x2*t^3 (X-Coordinate)
Bzy#=y1*(1-t)^3 + 3*vy1*(1-t)^2*t + 3*vy2*(1-t)*t^2 + y2*t^3 (Y-Coordinate)

where t is a value between 0 and 1

the equation of a line is:

A*x+B*y-C=0

substituting x and y values with Bzx and Bzy you have after solving for t something like this

Q*t^3 + R*t^2 + S*t + T = 0

you have now to find the polynomial roots of the above .

a 3 degree polynomial has 0 to 3 roots that means

0 no intersection

1 to 3 intersections at t=root(1) or t=root(2) etc.

and........

only values between 0 to 1 are real intersections


any ideas how to solve polynomials with Blitz+?

here my code now i need a solver

Function intersectBezier3Line(x1#,y1#,vx1#,vy1#,x2#,y2#,vx2#,vy2#,L1x#,L1y#,L2x#,L2y#)

        Local A#,B#,C#,E#,F#,G#,La#,Lb#,Lc#,Solution#

                A=3*vx1+x2-(3*vx2)-x1
		B=3*x1-(6*vx1)+(3*vx2)
		C=3*vx1-(3*x1)
		
                E=3*vy1+y2-(3*vy2)-y1
		F=3*y1-(6*vy1)+(3*vy2)
		G=3*vy1-(3*y1)

		La=L2y-L1y
		Lb=L1x-L2x
		Lc=L1y*(L2x-L1x) + L1x*(L1y-L2y)

		

                ax(4)=La*x1 + Lb*y1 + Lc
		ax(3)=La*C  + Lb*G
		ax(2)=La*B  + Lb*F
		ax(1)=La*A  + Lb*E
		
       FindRootsPoly3(ax(4),ax(3),ax(2),ax(1)) 

End Function