|
Author |
Topic: Finding overlaps on a (bezier) curve (Read 833 times) |
|
mflux
|
Finding overlaps on a (bezier) curve
« on: Oct 16th, 2004, 11:30pm » |
|
I wrote this for a project sometime over summer. It might prove useful to somebody out there... This function will find out if a bezier curve overlaps itself vertically, from left to right. It won't tell you how many numbers of overlaps, or where they occur, though. The function will return true if it finds an overlap, return false if no overlaps are found. It uses a brute force method, using an increment value to determine resolution of tests. Decrease this number to get more accurate results. This is useful for people making animation graphs, charts, or whatever UI/Software that demands non-overlapping bezier graphs. Code: boolean findOverlap(float a,float b,float c,float d) { float increment=.005; for(float t=increment;t<=1;t+=increment) { float prev=bezierPoint(a,b,c,d,t-increment); float cur=bezierPoint(a,b,c,d,t); if(prev>cur) return true; } return false; } |
|
|
|
|
|
|