Sign in to follow this  
Four

test if a point is inside a shape defined by quadratic B-splines

Recommended Posts

I got it working, based on the idea that if a point is inside it will need to pass through odd number of edges to escape in a linear direction. In my drawing I pick my Y, and get all intersections on that Y. Now I have an array of X values for a given Y. It worked fine, until I started using more complex shapes. I increased precision from float to double, and it made my results much better [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]. But still not good enough.

I don't know how to debug precision. When I step through the program this line right here has issues

[code]
// this is from the expanded bezier formula
A = (double)p[0].y + (double)p[2].y - 2.0*(double)p[1].y;
// of course down the line I divide by 2.0*A
// after quadratic formula I get a 't' which I plug into the formula below to get a (x, y) point of intersection

// this is the interpolation formula

Vector2D n;
float t_u;
t_u = 1.0 - t;
n = p[0]*t_u*t_u + p[1]*2*t_u*t + p[2]*t*t;
// p is a vector
[/code]

'A' goes really close to 0! I've been stuck on this problem for quite some time now. This is in my rendering loop I'm rendering a filled shape defined by this closed curve.

Share this post


Link to post
Share on other sites
Solved :)

I went for food came back and realized it. It degrades to a line ... SO SIMPLE. Just solve the linear equation and add to array done.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this