# Spline and ball hit testing

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

## Recommended Posts

Hello! I am working on a variant of break out and instead of using normal rectangles I'm using polygons. Hittesting the ball with the edges and the corners of the polygon is no problem. But I want some edges to be smooth. So I'm turning each "smooth corner" and the two connecting edges of it into the simplest form of spline, which is basically a two dimensional second order polynom. Does anyone know how to hittest this type of shape with a ball moving in a straight line?

##### Share on other sites
Wrong forum - moving to Game Programming.

##### Share on other sites
As long as you keep the curves more gentle than the (I'm presuming) circular ball there are a few short-cuts you can make. All you need is an inside / outside test, just move the curve 1 radius of the ball towards the ball then test if the centre of the ball is inside or outside the curve.

If you have the curve expressed as a simple equation just turn the equation into an inequality, pass the ball's centre into the equality and it should tell you inside / outside.

Otherwise the normal methods apply, the separating axis theorem (for convex), or a ray through the centre of the ball and through some part of the curve. Travel along the ray and count the number of times the ray crosses the curve. Using this you can work out if the ray is inside the curve or outside at the centre of the ball.

Another approach is rasterise the curve into a polygon. Then just use normal polygon collision methods which should be easy to look up. If you are rendering you will have to do this anyway.

I guess that last approach is to not use curves, or use curves for the editor but convert them in game.

[Edited by - Umbrae on April 22, 2008 7:45:58 AM]

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• ### Forum Statistics

• Total Topics
631438
• Total Posts
3000073
×