Johnsprogram asks,
I’m having a math-related crisis that one man (me) can not do alone. I’m trying to figure out a way to calculate the radius of the ellipse on the same angle as the light blue line; in other words, the length of the “mystery line.”
He attached a picture which didn’t do too much to help explain matters, but what he wanted to know was the distance from the centre of the ellipse to the edge, at a given angle.
We can assume that the ellipse is oriented vertically. TheĀ locus of the edge of the ellipse is, in this case,
where and
are the horizontal and vertical radii.
We want to know the length of the line heading at an angle from the vertical to the edge of the ellipse. Call the length
, so the co-ordinates of the end are given by
Substitute those into the first equation:
Take a factor of out:
and rearrange:
Here’s some code:
Graphics 600,600,0 an = 60 While Not (KeyHit(KEY_ESCAPE) Or AppTerminate()) ew# = MouseX()-300 eh# = MouseY()-300 SetColor 100,100,100 DrawOval 300-ew,300-eh,ew*2,eh*2 an:+1 l# = Sqr( 1/( (Sin(an)/ew)^2 + (Cos(an)/eh)^2) ) lx# = 300+l*Sin(an) ly# = 300-l*Cos(an) SetColor 0,0,255 DrawLine 300,300,lx,ly Flip Cls Wend