I'm trying to make a nice deflection effect in a little physics engine I've made. Right now it deflects nicely off the normal of a polygon edge. But instead of making a polygon with 100 edges to get a smooth effect of a "rounded deflection" I figured I could calculate the deflection normal using an ellipse instead.
So, what I'd really like is a function that takes a point P on a line segment and returns the normal N on the circumference of an imaginary ellipse(w,h). See the attached picture for some details.
To get a point on the circumference of an ellipse I'm pretty sure it's:
x=P.x+Math.sin()*w
y=P.y+Math.cos()*h
but how can I get the normal from that?
Here's a fiddle with an attempt to implement the answer by Dr BDO Adams.