Jump to content
  • Advertisement
Sign in to follow this  
Four

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

This topic is 2300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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


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


'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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!