08-30-2024, 05:43 AM
(08-30-2024, 04:21 AM)Pete Wrote: Yes, I recall how Bill didn't think using SQR could possibly work, until I did exactly that. Mostly thanks to _INTEGER64, it worked.
That reminds me....
Code: (Select All)Sub FC3 (cx, cy, r, clr&)
Line (cx - r, cy)-(cx + r, cy), clr&, BF
y = 1
r2 = r * r ' Dav mod
While y <= r
y2 = y * y
If y2 < r2 Then
x = Int(Sqr(r2 - y2))
Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
Line (cx - x, cy - y)-(cx + x, cy - y), clr&, BF
End If
y = y + 1
Wend
End Sub
Could be modified to...
Code: (Select All)Sub FC3 (cx, cy, r, clr&)
Dim x as Integer
Line (cx - r, cy)-(cx + r, cy), clr&, BF
r2 = r * r ' Dav mod
Do Until y > r
y = y + 1
y2 = y * y
If y2 < r2 Then
x = Sqr(r2 - y2)
Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
Line (cx - x, cy - y)-(cx + x, cy - y), clr&, BF
End If
Loop
End Sub
Pete
My thinking was to make use of something like this:
Code: (Select All)
Sub PreCalcX
For r = 0 To 500 'circles with a radius from 0 to 500
r2 = r * r
For y = 0 To r
y2 = y * y
x = Int(Sqr(r2 - y2))
CircleXPos(r, y) = x
Next
Next
End Sub
Precalculate all that math, and get rid of it completely. Just one quick lookup for that value rather than multiplying and all that.
It would seem to me that *this* should be much faster than everything else is:
Code: (Select All)
Sub StevePreCalcCircle (cx, cy, r, clr&)
$Checking:Off
For y = 0 To r
x = CircleXPos(r, y)
Line (cx - x, cy - y)-(cx + x, cy - y), clr&, BF
Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
Next
$Checking:On
End Sub
Just look up that one value from a precalculated list. And yet... almost impossibly... it's often not the fastest method we have available, when resting those speeds all side by side!
Are our arrays that slow?
Is the timer routine screwing up somewhere?
WTF is going on to give us the figures that we're getting??
I have no clue. I just found the results upper astonishing.