Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drawing an ellipse
#9
I know you wanted to avoid trig functions, but they are rather handy in this case. Here is one of the simplest trig methods I've found to construct an elliptical shape. The granularity of the image is 1/100th of a radian, so it is quite smooth to the eye. At least as good as my old eyes and laptop screen can reveal.

Code: (Select All)
'de La Hire's method of ellipse
'geometric construction of two concentric circles
'the outermost diameter equals the desired ellipse's
'semi major axis, while the inner circle matches the
'semi minor axis.
'a full 360ø rotation is executed and the positions
'are plotted using a COS function of the outer circle's
'resulting X position and SIN function of the inner
'circle's Y position.

SCREEN _NEWIMAGE(1024, 512, 32)
cen_x% = 512 '                             screen center x
cen_y% = 256 '                             screen center y
semi_maj% = 200 '                          Semi major axis of ellipse i.e. outer circle
semi_min% = 50 '                           Semi minor axis of ellipse i.e. inner circle

PSET (semi_maj% + cen_x%, cen_y%) '        pre-position graphics cursor
FOR ang = 0 TO 2 * _PI STEP .01 '          granularity of 1/100 radian
    x% = semi_maj% * COS(ang) + cen_x% '   x position a COS function of the outer circle
    y% = semi_min% * SIN(ang) + cen_y% '   y position a SIN function of the inner circle
    LINE STEP(0, 0)-(x%, y%) '             line from previous cursor position
NEXT ang


Attached Files Image(s)
   
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply


Messages In This Thread
Drawing an ellipse - by PhilOfPerth - 07-01-2023, 08:14 AM
RE: Drawing an ellipse - by bplus - 07-01-2023, 10:04 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-01-2023, 11:34 AM
RE: Drawing an ellipse - by OldMoses - 07-01-2023, 05:23 PM
RE: Drawing an ellipse - by bplus - 07-01-2023, 05:34 PM
RE: Drawing an ellipse - by PhilOfPerth - 07-01-2023, 11:26 PM
RE: Drawing an ellipse - by mnrvovrfc - 07-02-2023, 01:07 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-02-2023, 01:21 AM
RE: Drawing an ellipse - by OldMoses - 07-02-2023, 02:12 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-03-2023, 12:35 AM
RE: Drawing an ellipse - by mnrvovrfc - 07-03-2023, 01:40 AM
RE: Drawing an ellipse - by OldMoses - 07-03-2023, 03:52 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-03-2023, 06:12 AM
RE: Drawing an ellipse - by SMcNeill - 07-03-2023, 06:16 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-03-2023, 06:19 AM
RE: Drawing an ellipse - by SMcNeill - 07-03-2023, 06:24 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-03-2023, 07:04 AM
RE: Drawing an ellipse - by mnrvovrfc - 07-03-2023, 06:34 AM
RE: Drawing an ellipse - by johnno56 - 07-03-2023, 07:06 AM
RE: Drawing an ellipse - by SMcNeill - 07-03-2023, 07:18 AM
RE: Drawing an ellipse - by bplus - 07-03-2023, 12:13 PM
RE: Drawing an ellipse - by OldMoses - 07-04-2023, 06:18 PM
RE: Drawing an ellipse - by bplus - 07-04-2023, 11:31 PM
RE: Drawing an ellipse - by PhilOfPerth - 07-05-2023, 01:58 AM
RE: Drawing an ellipse - by bplus - 07-05-2023, 02:28 AM
RE: Drawing an ellipse - by PhilOfPerth - 07-05-2023, 02:47 AM
RE: Drawing an ellipse - by OldMoses - 07-06-2023, 09:30 PM



Users browsing this thread: 1 Guest(s)