Personal Computer News


Flattening The Oric's Circles For Ellipses

 
Published in Personal Computer News #076

Flattening the Oric's Circles for Ellipses

Q. I can work out how to draw circles on my Oric 1, but when it comes to ellipses I'm stumped. Has the formula got something to do with the height to width ratio?

Peter Wylie, Knutsford, Cheshire

A. The formula for an ellipse is virtually the same as for a circle. The only difference is that with an ellipse you must specify two radii - one for the vertical, the other for the horizontal. If these are the same your height:width ratio is one, and you get a circle.

The following subroutine should perform the calculation and do what you want. The variables XC and YC are the x and y coordinates of the centre, XR is the horizontal radius and YR the vertical.

XR/YR gives you the height:width ratio.

1000 V=(22/7)/180:REM OR PI/180
1010 FOR D=540 TO 180 STEP +10:ED=D*V
1020 XP=XR*SIN(ED):YP=YR*COS(ED)
1030 XP=XC+XP:YP=YC+YP
1040 CURSET XP,YP,1:NEXT:RETURN

Peter Wylie