Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a custom physics engine to accompany a level-editor. This image shows how the level-editor outputs levels:

enter image description here

Now, some explanation is in order. The curve is defined by the red points. After they are connected in threes by circles (yellow lines show these circles), a system connects them in a 'streamlined' way - as shown by the blue lines. This makes the curves flow seamlessly.

Now, these curves are 'irregular,' so to say. For the accompanying physics engine - how do I detect the angle made between a pixel on the curve and a colliding circle (per-pixel collision check)?

share|improve this question
Possible duplicate:… – Byte56 Aug 28 '13 at 13:13
I saw that post, but I'm not exactly dealing with bezier curves. – MemoNick Aug 28 '13 at 13:15
Wouldn't you just take the two adjacent pixels to form a line? Then you can calculate the "angle" between the pixel and colliding circle rather easily. – Byte56 Aug 28 '13 at 13:23
How irregular are your curves? Aren't they cubic splines? If you invented them and it doesn't bother you in sharing the idea, put the math online so we may help. I think there's an ocean on info on spline-circle intersection out there. What did you look for before deciding it's not what you need/want? – teodron Aug 28 '13 at 13:23
@Byte56 I don't think that would work really. If you're taking adjacent pixels, you'll only have a handful different gradients (and hence, lines). – MemoNick Aug 28 '13 at 13:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.