• Print

Author Topic: Corrected CIRCLE command  (Read 505 times)

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Corrected CIRCLE command
« on: February 02, 2013, 06:17:10 PM »
I was not sure where to put this code, as it's not a full library but should be included in a program as such.  Moderator, please move to appropriate location if this is not it.

The QB64 CIRCLE command works great if you are drawing full circles.  But, the command computes start and/or end radians incorrectly when drawing partial circles (arcs).  Save the code below as CIRCLES.BI and then include the file by typing the following line of code at the very bottom of your program to use it:

'$INCLUDE:'CIRCLES.BI'

Of course, you could simply copy and paste the subroutine right into your code if you wish as well.

I have not done any speed testing on the code to see how it compares to QB64's CIRCLE command.  I believe I have the code as optimized as possible, but if you can improve upon it please do and report your changes here please.  Again, you will only need this replacement command if you plan on drawing anything other than full circles. The syntax is set up exactly the same as the CIRCLE command:

CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!

Code: [Select]
SUB CIRCLES (cx%, cy%, r!, c~&, s!, e!, a!)

'**
'** QB64 temporary replacement CIRCLE command.
'**
'** The CIRCLE command in QB64 has a few bugs listed below:
'**
'** - radian end points are not calculate properly when creating arcs
'** - center line to radian end points do not close properly due to previous bug listed
'**
'** This circle command replacement works very similiarly to the native CIRCLE command:
'**
'** SYNTAX: CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!
'**
'**   x%            - center X coordinate of circle
'**   y%            - center Y coordinate of circle
'**   radius!       - the radius of the circle
'**   color~&       - the circle's color
'**   start_radian! - the radian on circle curcunference to begin drawing at
'**   end_radian!   - the radian on circle circumference to end drawing at
'**   aspect_ratio! - the aspect ratio of the circle
'**
'** NOTE: unlike the native CIRCLE command, all arguments MUST be supplied. For example,
'**       with the native command this will draw a perfect circle with the default color,
'**       start radian, end radian and aspect ratio:
'**
'**       CIRCLE (319, 239), 100
'**
'**       To do the same thing with this replacement command you must supply everything:
'**
'**       CIRCLES 319, 239, 100, _RGB32(255, 255, 255), 0, 0, 0
'**
'** ACKNOWLEGEMENTS: The FOR/NEXT step formula was was written by Codeguy for Unseen
'**                  Machine's Visual library EllipseXS command. Specifically:
'**                         MinStep! = 1 / (2 * 3.1415926535 * Radius!)
'**
'**
'** Includes performance tweaks made by SMcNeill on 02/02/13 - specifically removing a few redundant * -1
'** statements and converting the FOR/NEXT loop to a DO loop for a ~3% increase in performance.
'**
'** Corrected bug in which variables being passed in were being modified and passed back - 02/02/13
'**

DIM s%, e%, nx%, ny%, xr!, yr!, st!, en!, asp! '     local variables used

st! = s! '                                           copy start radian to local variable
en! = e! '                                           copy end radian to local variable
asp! = a! '                                          copy aspect ratio to local variable
IF asp! <= 0 THEN asp! = 1 '                         keep aspect ratio between 0 and 4
IF asp! > 4 THEN asp! = 4
IF asp! < 1 THEN xr! = r! * asp! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF asp! > 1 THEN yr! = r! * asp! ELSE yr! = r!
IF st! < 0 THEN s% = -1: st! = -st! '                remember if line needs drawn from center to start radian
IF en! < 0 THEN e% = -1: en! = -en! '                remember if line needs drawn from center to end radian
IF s% THEN '                                         draw line from center to start radian?
    nx% = cx% + xr! * COS(st!) '                     yes, compute starting point on circle's circumference
    ny% = cy% + yr! * -SIN(st!)
    LINE (cx%, cy%)-(nx%, ny%), c~& '                draw line from center to radian
END IF
IF en! <= st! THEN en! = en! + 6.2831852 '           come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
c! = st! '                                           cycle from start radian to end radian
DO
    nx% = cx% + xr! * COS(c!) '                      compute next point on circle's circumfrerence
    ny% = cy% + yr! * -SIN(c!)
    PSET (nx%, ny%), c~& '                           draw the point
    c! = c! + stepp!
LOOP UNTIL c! >= en!
IF e% THEN LINE -(cx%, cy%), c~& '                   draw line from center to end radian if needed

END SUB

UPDATE: code now updated to reflect SMcNeill's tweaks as listed below.

UPDATE2: Variables being passed in were being modified and passed back out. This has been corrected.



« Last Edit: February 02, 2013, 08:18:28 PM by TerryRitchie »

OlDosLover

  • Hero Member
  • *****
  • Posts: 3972
  • OlDosLover
    • Email
Re: Corrected CIRCLE command
« Reply #1 on: February 02, 2013, 06:24:01 PM »
Hi all,
    Thanks Terry!
OlDosLover.

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Corrected CIRCLE command
« Reply #2 on: February 02, 2013, 06:33:32 PM »
Quote from: OlDosLover on February 02, 2013, 06:24:01 PM
Hi all,
    Thanks Terry!
OlDosLover.

Welcome :)

SMcNeill

  • Hero Member
  • *****
  • Posts: 2452
    • Email
Re: Corrected CIRCLE command
« Reply #3 on: February 02, 2013, 07:29:04 PM »
A few minor tweaks which should improve performance just a bit.   

Code: [Select]
SUB CIRCLES (cx%, cy%, r!, c~&, s!, e!, a!)

'**
'** QB64 temporary replacement CIRCLE command.
'**
'** The CIRCLE command in QB64 has a few bugs listed below:
'**
'** - radian end points are not calculate properly when creating arcs
'** - center line to radian end points do not close properly due to previous bug listed
'**
'** This circle command replacement works very similiarly to the native CIRCLE command:
'**
'** SYNTAX: CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!
'**
'**   x%            - center X coordinate of circle
'**   y%            - center Y coordinate of circle
'**   radius!       - the radius of the circle
'**   color~&       - the circle's color
'**   start_radian! - the radian on circle curcunference to begin drawing at
'**   end_radian!   - the radian on circle circumference to end drawing at
'**   aspect_ratio! - the aspect ratio of the circle
'**
'** NOTE: unlike the native CIRCLE command, all arguments MUST be supplied. For example,
'**       with the native command this will draw a perfect circle with the default color,
'**       start radian, end radian and aspect ratio:
'**
'**       CIRCLE (319, 239), 100
'**
'**       To do the same thing with this replacement command you must supply everything:
'**
'**       CIRCLES 319, 239, 100, _RGB32(255, 255, 255), 0, 0, 0
'**
'** ACKNOWLEGEMENTS: The FOR/NEXT step formula was was written by Codeguy for Unseen
'**                  Machine's Visual library EllipseXS command. Specifically:
'**                         MinStep! = 1 / (2 * 3.1415926535 * Radius!)
'**

DIM s%, e%, nx%, ny%, xr!, yr! '                 local variables used

IF a! <= 0 THEN a! = 1 '                         keep aspect ratio between 0 and 4
IF a! > 4 THEN a! = 4
IF a! < 1 THEN xr! = r! * a! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF a! > 1 THEN yr! = r! * a! ELSE yr! = r!
IF s! < 0 THEN s% = -1: s! = -s! '               remember if line needs drawn from center to start radian
IF e! < 0 THEN e% = -1: e! = -e! '               remember if line needs drawn from center to end radian
IF s% THEN '                                     draw line from center to start radian?
    nx% = cx% + xr! * COS(s!) '                  yes, compute starting point on circle's circumference
    ny% = cy% + yr! * -SIN(s!)
    LINE (cx%, cy%)-(nx%, ny%), c~& '            draw line from center to radian
END IF
IF e! <= s! THEN e! = e! + 6.2831852 '           come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
c! = s! '                                        cycle from start radian to end radian
DO
    nx% = cx% + xr! * COS(c!) '                  compute next point on circle's circumfrerence
    ny% = cy% + yr! * -SIN(c!)
    PSET (nx%, ny%), c~& '                       draw the point
    c! = c! + stepp!
LOOP UNTIL c! >= e!
IF e% THEN LINE -(cx%, cy%), c~& '               draw line from center to end radian if needed

END SUB

Just minor things:
Changed FOR to DO
Changed -1 * number to -number a few places.

There's nothing else I see to change to optimize any better for speed, unless one wants to swap it to work with a _MEMIMAGE.   As it is though, it seems plenty speedy to me already :)


*************** Edit

For a speed check I worked up the following little routine to go before each sub:

Code: [Select]
SCREEN _NEWIMAGE(1280, 720, 32)
DIM count AS LONG
t# = TIMER(0.001)
DO
    count = count + 1
    CIRCLES 640, 360, 100, _RGB32(255, 0, 0), 0, 6.28318530718, 1
LOOP UNTIL t# + 10 < TIMER(0.001)

PRINT count

The original runs ~21100 loops in 10 seconds on my machine.  The version I put up runs at ~ 21600 loops in 10 seconds.   Less than a 3% performance boost, but sometimes you just need all the little speed tweaking you can get with images.  :)
« Last Edit: February 02, 2013, 07:38:21 PM by SMcNeill »
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Corrected CIRCLE command
« Reply #4 on: February 02, 2013, 07:46:07 PM »
Excellent, thanks for the tweaks.  I updated the code in the original post with your tweaks.
« Last Edit: February 02, 2013, 07:52:40 PM by TerryRitchie »

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Corrected CIRCLE command
« Reply #5 on: February 02, 2013, 08:12:34 PM »
Just corrected a bug and placed the corrected code in the original post.

The start radian, end radian and aspect ratio variables were being modified and passed back to the calling routine.  This has been corrected by copying these values to local variables in the subroutine.

codeguy

  • Hero Member
  • *****
  • Posts: 3555
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Corrected CIRCLE command
« Reply #6 on: February 04, 2013, 07:40:12 AM »
thanks and i'm grateful for the nod to codeguy and his skillz ;D always glad to help. given its speed, it will be a nice library to add to completed libs, especially if you can make it work for ellipsoidal sections. i may work on making it work for those too, but i can tell ya it'll probably be slow. i will see if i can make an ellipse paint will not spill through. time to go to work again ;D speaking of which, does anyone know anyone who might be willing to hire (pt/ft or even on a per-project basis) an expert but non-degreed programmer? i happen to know one quite well. ;) perhaps others do too.
« Last Edit: February 04, 2013, 07:46:10 AM by codeguy »
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

codeguy

  • Hero Member
  • *****
  • Posts: 3555
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Corrected CIRCLE command
« Reply #7 on: February 04, 2013, 08:16:42 AM »
this is probably gonna be slow
Code: [Select]
but mine will probably be faster.
INPUT "a,b="; a, b
a=ABS(a): b=ABS(b)
IF a < b THEN x=a: a=b: b=x
IF b < 0.28*a THEN
 P = 4*a*cayley((b/a)^2)
ELSE
 h = ((a-b)/(a+b))^2
 P = pi*(a+b)*gk(h)
ENDIF
PRINT "Ellipse Perimeter ="; P
END

DEFDBL A-Z
FUNCTION gk (h)
z = 0: x = 1: n = 0
REM Add 1 (to z) afterwards...
 WHILE z + x <> z
 n = n + 1
 x = h * x * ((n-1.5)/n)^2
 z = z + x
 WEND
gk = 1 + z
END FUNCTION
 

DEFDBL A-Z
FUNCTION cayley (x)
y = LOG(16# / x) - 1
t = x / 4
n = 1
z = 0: REM Add 1 afterwards.
u = t * y
v = (n - .5) / n
w = .5 / ((n - .5) * n)
 WHILE z <> z + u
 z = z + u
 n = n + 1
 t = x * t * v
 v = (n - .5) / n
 t = t * v
 y = y - w
 w = .5 / ((n - .5) * n)
 y = y - w
 u = t * y
 WEND
cayley = 1 + z
END FUNCTION
REM Multiplications minimized
code from: http://www.numericana.com/answer/ellipse.htm#gausskummer
to find the circumference of an ellipse in reasonable time. this might become the start of an ellipse-drawing routine that renders them without intervening gaps. however, i suspect it has something to do with the apect ratios and a simple 1/(aspect ratio) may be sufficient, provided its inverse is less than 1 but greater than 0. so for a circle of AR=1/2 (flatter, longer) or ar=2/1 (taller, narrower), the inverse may be 2. i shall see. the reason for this is the circumference for these ellipses is the same except they are essentially rotated by 90 degrees. and for the case of a circle (AR=1), this should reduce to the general formula for the circumference of a circle.
however, you may try this:
Code: [Select]
function MinEllipseStep#(radius1!, radius2!)
absR1!=abs(radius1!)
absr2!=abs(radius2!)
if absr1!<absr2! then
inverse!=absr1!/absr2!
else
inverse!=absr2!/absr1!
end if
MinEllipseStep#=1/(3.1415926535#*(absr1!+absr2!))/inverse!
end function
umm... i do not have capability of testing this but this is the most reasonable approximation of the number of pixels around an ellipse. it will be slower for highly eccentric ellipses.
« Last Edit: February 05, 2013, 02:24:09 PM by codeguy »
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

DarthWho

  • Hero Member
  • *****
  • Posts: 3857
  • Timelord of the Sith
Re: Corrected CIRCLE command
« Reply #8 on: February 04, 2013, 02:58:03 PM »
well here is a quick mod to SMcNeil's version of Terry's code to boost speed a bit(~2.8 circles drawn with this version for every circle that SMcNeil's version draws on my computer so a 180% improvement):
EDIT: Changes include SIN and COS only called once (unnoticeable improvement but still slightly faster) and usage of Resonant filter to calculate SIN and COS
Code: [Select]
SUB CIRCLES (cx%, cy%, r!, c~&, s!, e!, a!)

'**
'** QB64 temporary replacement CIRCLE command.
'**
'** The CIRCLE command in QB64 has a few bugs listed below:
'**
'** - radian end points are not calculate properly when creating arcs
'** - center line to radian end points do not close properly due to previous bug listed
'**
'** This circle command replacement works very similiarly to the native CIRCLE command:
'**
'** SYNTAX: CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!
'**
'**   x%            - center X coordinate of circle
'**   y%            - center Y coordinate of circle
'**   radius!       - the radius of the circle
'**   color~&       - the circle's color
'**   start_radian! - the radian on circle curcunference to begin drawing at
'**   end_radian!   - the radian on circle circumference to end drawing at
'**   aspect_ratio! - the aspect ratio of the circle
'**

'** NOTE: unlike the native CIRCLE command, all arguments MUST be supplied. For example,
'**       with the native command this will draw a perfect circle with the default color,
'**       start radian, end radian and aspect ratio:
'**
'**       CIRCLE (319, 239), 100
'**
'**       To do the same thing with this replacement command you must supply everything:
'**
'**       CIRCLES 319, 239, 100, _RGB32(255, 255, 255), 0, 0, 0
'**
'** ACKNOWLEGEMENTS: The FOR/NEXT step formula was was written by Codeguy for Unseen
'**                  Machine's Visual library EllipseXS command. Specifically:
'**                         MinStep! = 1 / (2 * 3.1415926535 * Radius!)
'**
'**
'** Includes performance tweaks made by SMcNeill on 02/02/13 - specifically removing a few redundant * -1
'** statements and converting the FOR/NEXT loop to a DO loop for a ~3% increase in performance.
'**
'** Corrected bug in which variables being passed in were being modified and passed back - 02/02/13
'**

DIM s%, e%, nx%, ny%, xr!, yr!, st!, en!, asp! '     local variables used

st! = s! '                                           copy start radian to local variable
en! = e! '                                           copy end radian to local variable
asp! = a! '                                          copy aspect ratio to local variable
IF asp! <= 0 THEN asp! = 1 '                         keep aspect ratio between 0 and 4
IF asp! > 4 THEN asp! = 4
IF asp! < 1 THEN xr! = r! * asp! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF asp! > 1 THEN yr! = r! * asp! ELSE yr! = r!
IF st! < 0 THEN s% = -1: st! = -st! '                remember if line needs drawn from center to start radian
IF en! < 0 THEN e% = -1: en! = -en! '                remember if line needs drawn from center to end radian
CC = COS(st!)
SS = SIN(st!) '
IF s% THEN '                                         draw line from center to start radian?
    nx% = cx% + xr! * CC ' COS(st!) '                     yes, compute starting point on circle's circumference
    ny% = cy% + yr! * -SS ' -SIN(st!)
    LINE (cx%, cy%)-(nx%, ny%), c~& '                draw line from center to radian
END IF
IF en! <= st! THEN en! = en! + 6.2831852 '           come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
pin = 3.14159265 * stepp!
'                  cycle from start radian to end radian
DO
    nx% = cx% + xr! * CC '                      compute next point on circle's circumfrerence
    ny% = cy% + yr! * -SS
    PSET (nx%, ny%), c~& '                           draw the point
    CC = CC - SS * pin '                       this is magic to most of you...
    SS = SS + CC * pin '                      This is known as a resonant filter
    c! = c! + stepp!

LOOP UNTIL c! >= en!
IF e% THEN LINE -(cx%, cy%), c~& '                   draw line from center to end radian if needed

END SUB

hope you all enjoy this variant

note compared to the c++ code that Galleon uses both versions are slow by an order of magnitude. this version is just 180% faster than the previous one.
EDIT: 180% seems to be the minimum; on a recent run I got 253% improvement over the previous model.
« Last Edit: February 05, 2013, 07:04:42 AM by DarthWho »
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

DarthWho

  • Hero Member
  • *****
  • Posts: 3857
  • Timelord of the Sith
Re: Corrected CIRCLE command
« Reply #9 on: February 05, 2013, 12:54:52 PM »
Might I suggest using the following approximation for the Circumference of an ellipse:
Code: [Select]
PRINT ELIAPPR(10, 1)

FUNCTION ELIAPPR (A AS SINGLE, B AS SINGLE)
Pi = 3.14159265359
AA = ABS(A)
BB = ABS(B)
eli = (AA - BB) / (AA + BB)
eli = eli * eli
eli = eli + eli + eli
ELIAPPR = Pi * (AA + BB) * (1 + eli / (10 + SQR(4 - eli)))
END FUNCTION

as far as i can tell it's worst case accuracy is 99.95% accurate
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Corrected CIRCLE command
« Reply #10 on: February 05, 2013, 01:05:35 PM »
Darth, thanks for the changes!  I'm still trying to figure out what you did.  :P

Mrwhy

  • Hero Member
  • *****
  • Posts: 2908
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Corrected CIRCLE command
« Reply #11 on: February 05, 2013, 01:21:53 PM »
Quote from: DarthWho on February 05, 2013, 12:54:52 PM
Might I suggest using the following approximation for the Circumference of an ellipse:
Code: [Select]
PRINT ELIAPPR(10, 1)

FUNCTION ELIAPPR (A AS SINGLE, B AS SINGLE)
Pi = 3.14159265359
AA = ABS(A)
BB = ABS(B)
eli = (AA - BB) / (AA + BB)
eli = eli * eli
eli = eli + eli + eli
ELIAPPR = Pi * (AA + BB) * (1 + eli / (10 + SQR(4 - eli)))
END FUNCTION

as far as i can tell it's worst case accuracy is 99.95% accurate

So this is also a way to calculate 2/Pi      (put a=0 in it)

codeguy

  • Hero Member
  • *****
  • Posts: 3555
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Corrected CIRCLE command
« Reply #12 on: February 05, 2013, 02:16:26 PM »
you may wanna check out cgEllipseMapImage, which you can replace the image with a solid-colored image or even a sprite sheet with solid-colored images to fill ellipsoidal regions with a sold color. this will eliminate the need for drawing the borders and give a solid fill. http://www.qb64.net/forum/index.php?topic=3002.msg26726#msg26726 or ya might wanna use a value equalling 1/(aspect ratio), for example an ellipse twice as wide as it is high or twice as high as it is tall, use a value twice as large as the calculation yielded from MinStep! calculation used in unseenmachine's library.
« Last Edit: February 05, 2013, 02:23:09 PM by codeguy »
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

DarthWho

  • Hero Member
  • *****
  • Posts: 3857
  • Timelord of the Sith
Re: Corrected CIRCLE command
« Reply #13 on: February 05, 2013, 03:13:21 PM »
Quote from: TerryRitchie on February 05, 2013, 01:05:35 PM
Darth, thanks for the changes!  I'm still trying to figure out what you did.  :P

Essentially the most important change I made did was replace a structure similar to this:

Code: [Select]
SCREEN 13
Rad = 19
x = 320 / 2
y = 200 / 2
DO
    X2 = x + Rad * COS(N)
    Y2 = y - Rad * SIN(N)
    PSET (X2, Y2)
    N = N + 0.01
LOOP UNTIL SIN(N) < 0 AND COS(N) > 0
with:
Code: [Select]
SCREEN 13
Rad = 19
x = 320 / 2
y = 200 / 2
'
Pi = 3.14159265
A = .01
c = 1
s = 0
DO
    X2 = x + Rad * c
    Y2 = y - Rad * s
    c = c - s * A
    s = s + c * A
    PSET (X2, Y2)
LOOP UNTIL s < 0 AND c > 0
« Last Edit: February 05, 2013, 09:59:34 PM by DarthWho »
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

codeguy

  • Hero Member
  • *****
  • Posts: 3555
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Corrected CIRCLE command
« Reply #14 on: February 06, 2013, 07:30:52 AM »
you can also calculate points along the ellipse and do
line (PreviousCalcx,PreviousCalcY)-(currentCalcX,CurrentCalcY)...
PreviousCalcx=currentCalcX
PreviousCalcY=CurrentCalcY
for extremes of aspect ratio, this will still yield polygonal renderings, but that's due to limitations in screen resolution. a simple mod to DrawPolySimple in my NSpace demos should suffice. http://www.qb64.net/forum/index.php?topic=1281.msg9304#msg9304

a good approximation for circumference of an ellipse:
EllipsePerimeter#=4*(a+b)*(pi/4)^((4*a*b)/(a+b)^2)
there are more accurate versions, but this one is accuate to .17%, which in many cases is decent enough. the exact forumula converges far too slowly to be useful. ramanujan also has some pretty good contenders -- one smart friggin' eastern indian.
« Last Edit: February 13, 2013, 02:53:19 PM by codeguy »
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

  • Print