K
K
keltkelt2020-06-03 18:12:45
Algorithms
keltkelt, 2020-06-03 18:12:45

Algorithm for the correct circle of cells (pixels)?

In general, my task is more complicated:

Given the radius of a cylinder of cubes.

The height of the cylinder is half the radius.

You need to get an array with the relative coordinates of the cubes that make up the cylinder. Also, together with the coordinates, the distance from the cube to the center of the cylinder is stored. Here is a class for storing information of one cube.

data class Point(val x: Int, val y: Int, val z: Int, val distance: Double)


I decided to simplify the task and first understand the principle of correctly constructing a beautiful circle from cubes (so that later I can build a cylinder from many circles). In theory, you can first build a square, and then subtract the angles according to some principle.

I went to the site with pixels and looked at what beautiful circles look like. Well, now .... I suffer) Maybe you know by what principle you can do this?

5ed7bddca00c4172926825.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Armenian Radio, 2020-06-03
@keltkelt

Timeless classic

P
PeeX, 2020-06-03
@PeeX

there is also a book, Programming graphics for windows
Well, or any similar book

M
mayton2019, 2020-06-09
@mayton2019

Pixel art is an artistic technique that has nothing to do with engineering graphics, for example.
Roughly speaking, a perfectly pixelated circle can look ugly in your game.
And if he cut corners, then you can achieve visual beauty. Only from the point of view of mathematics, it will already be an oval or RoundRect.
I have nothing against Bresenham's algorithms. But this is about something else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question