Drawing a circle, point-by-point, without floating point support
11–20 of 42 posts
Re: Drawing a circle, point-by-point, without floating point support
#12You can always try Bresenham’s circle drawing algorithm.
This is the era where prior art doesn't exist. Why read a book when you can blog about discovering "something new". I could probably make a killing blogging about my "discovery" of the algorithms in the book "Hacker's Delight".
There happens to be a Wikipedia page on "Midpoint circle algorithm": https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
The page claims, "Bresenham's circle algorithm is derived from the midpoint circle algorithm."
The author of this blog post even made it clear, at the end of their article, that... "many explanations of midpoint algorithm use the final, optimized version. But I added several unoptimized steps."
I think there's a lot of value in a blogpost that demonstrates how someone could re-derive a widely-used algorithm from scratch.
Re: Drawing a circle, point-by-point, without floating point support
#13I love Yurichev's books on assembly language, and he gives them away (CC-BY-4.0). https://beginners.re/
Re: Drawing a circle, point-by-point, without floating point support
#14You can always try Bresenham’s circle drawing algorithm.
Back in the '80s in Bulgaria, I was only able to find the Bresenham's algorithm for circles, but needed to draw an ellipse (in 6052 assembly, well, machine code), and was so proud that I manage to do it.
Re: Drawing a circle, point-by-point, without floating point support
#15> It requires only additions, subtractions and bit shifts: 2x is the same as x Does any of this mean anything in JS, where AFAIK there are no real ints? 2x is an fpu operation under the hood, and not a bit shift.
I think, using the `(…) | 0` (expression binary ORed with zero) construct most JS engines will use true integers in optimized code.
Re: Drawing a circle, point-by-point, without floating point support
#16Earlier quoted context omitted.
Back in the '80s in Bulgaria, I was only able to find the Bresenham's algorithm for circles, but needed to draw an ellipse (in 6052 assembly, well, machine code), and was so proud that I manage to do it.
Did it work for any axes?
Re: Drawing a circle, point-by-point, without floating point support
#17Re: Drawing a circle, point-by-point, without floating point support
#18> It requires only additions, subtractions and bit shifts: 2x is the same as x Does any of this mean anything in JS, where AFAIK there are no real ints? 2x is an fpu operation under the hood, and not a bit shift.
For bitwise operations, JavaScript will first convert the number to a 32-bit two's complement signed integer.
Re: Drawing a circle, point-by-point, without floating point support
#19You can always try Bresenham’s circle drawing algorithm.
This is the era where prior art doesn't exist. Why read a book when you can blog about discovering "something new". I could probably make a killing blogging about my "discovery" of the algorithms in the book "Hacker's Delight".
I guess I shouldn't be surprised, after all, I've met a lot of people.
Re: Drawing a circle, point-by-point, without floating point support
#20I love Yurichev's books on assembly language, and he gives them away (CC-BY-4.0). https://beginners.re/
Actually that book is paywalled now. It's been somewhat of a controversy that people contributed to the book thinking it was a community resource but now it's unavailable.
still, controversial indeed.
Weirdly, the book itself says:
> Q: May I print this book / use it for teaching? > A: Of course! That’s why the book is licensed under the Creative Commons license (CC BY-SA 4.0)
So it would be legal for anyone else to host this.