Drawing a circle, point-by-point, without floating point support
1–10 of 42 posts
Re: Drawing a circle, point-by-point, without floating point support
#2No post body was provided.
Re: Drawing a circle, point-by-point, without floating point support
#3> It requires only additions, subtractions and bit shifts: 2x is the same as xDoes 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.
Re: Drawing a circle, point-by-point, without floating point support
#4> 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 guess JS is only used as a tool to demonstrate the algorithm.
Re: Drawing a circle, point-by-point, without floating point support
#5You can always try Bresenham’s circle drawing algorithm.
Re: Drawing a circle, point-by-point, without floating point support
#6You can always try Bresenham’s circle drawing algorithm.
Beat me to it. And there are several optimizations on top that by, more or less, by reflecting the points as you compute one quadrant of the circle.
Re: Drawing a circle, point-by-point, without floating point support
#7You 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".
Re: Drawing a circle, point-by-point, without floating point support
#8You 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
#9There's an even simpler algorithm if you're fine with "close enough" circles: https://news.ycombinator.com/item?id=15266331
Re: Drawing a circle, point-by-point, without floating point support
#10> 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.