Explain the Donuts as Old as Ears Part 3
Now what's left is what's happening in the nested for loop You may have seen r 1 sin θ and r 1 cos θ
These are used to make circles in 2d diagrams
and r 2 are used to keep the distance between the circles so that they do not overlap
So, r 2 > r 1 because r 2 starts from the origin to the center of the circle
Now, for overwhelming matrix multiplication, we will create a single row
C language
singlerow circle = {2 cos(theta), sin(theta), 0};
java language
singlerow circle = new singlerow(2 math.cos(theta), math.sin(theta), 0);
Now make 3 matrices ry, rx, rz, which will help us rotate the circle and donuts
java language
// rotation on y-axis matrix ry = new matrix( new singlerow(math.cos(phi), 0, math.sin(phi)), new singlerow(0, 1, 0), new singlerow(-math.sin(phi), 0, math.cos(phi)) ); // rotation on x-axis matrix rx = new matrix( new singlerow(1, 0, 0), new singlerow(0, math.cos(a), math.sin(a)), new singlerow(0, -math.sin(a), math.cos(a)) ); // rotation on z-axis matrix rz = new matrix( new singlerow(math.cos(b), math.sin(b), 0), new singlerow(-math.sin(b), math.cos(b), 0), new singlerow(0, 0, 1) );
C language
// rotation on y-axis matrix ry = {{cos(phi), 0, sin(phi)}, {0, 1, 0}, {-sin(phi), 0, cos(phi)}}; // rotation on x-axis matrix rx = {{1, 0, 0}, {0, cos(a), sin(a)}, {0, -sin(a), cos(a)}}; // rotation on z-axis matrix rz = {{cos(b), sin(b), 0}, {-sin(b), cos(b), 0}, {0, 0, 1}};
Using the multiplication function we created earlier, we will get the rotated donut coordinates
C language
singlerow donut = multiple(circle, ry); singlerow rotatex = multiply(donut, rx); // we will consider it as [nx, ny, nz] singlerow spinningdonut = multiply(rotatex, rz);
java language
singlerow donut = matrix.multiply(circle, ry); singlerow rotatex = matrix.multiply(donut, rx); // we will consider it as [nx, ny, nz] singlerow spinningdonut = matrix.multiply(rotatex, rz);
We will make recinz, which will be the countdown of nz 5 (distance from camera)
float recinz = 1 / (spinningdonut.a3 5);
int x = 40 30 * spinningdonut.a1 * recinz; int y = 12 15 * spinningdonut.a2 * recinz; // o is index of current buffer int o = x screen_width * y;
screen_height / 2 should be 11, but we now choose 12
What are 30 and 15? I don't know and multiply by recinz, why? I don't know there are too many unsolved mysteries in the donut code
Now to make it 3d we need some parts to shine
To do this, we need to find
n = ny - nz
- 2 sinb cosphhi cosθ
- 2 sinb cosψ
2 cosb sina sinphi
2 cosa sinphi
n between 0 and √2 Now multiply n by 8, with a maximum of 11
int l = n * 8
To print it with brightness, we will create an array of characters from the lowest to the highest brightness
char charopts[] = ".,-~:;=!*#$@";
or
char[] charopts = {'.', ',', '-', '~', ':', ';', '=', '!', '*', '#', '$', '@'};
Now is the last part to check whether:
x y recinz > zbuffer[0]
If so, then
if (zBuffer[o] 0 ? L : 0]; zBuffer[o] = reciNz; }
If l is negative, use charopts[0]/period(.)
The above is the detailed content of Explain the Donuts as Old as Ears Part 3. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Factors of rising virtual currency prices include: 1. Increased market demand, 2. Decreased supply, 3. Stimulated positive news, 4. Optimistic market sentiment, 5. Macroeconomic environment; Decline factors include: 1. Decreased market demand, 2. Increased supply, 3. Strike of negative news, 4. Pessimistic market sentiment, 5. Macroeconomic environment.

The most worth investing in 2025: Cloud mining strategy without eyeing the market If you want to invest in cryptocurrencies in 2025 and don’t want to pay attention to market fluctuations all the time, then cloud mining may be your ideal choice. Cloud mining can easily generate Bitcoin and other digital currencies without expensive mining machines and complex settings. A number of new cloud mining platforms have emerged in 2025, making it easier than ever to get started. Whether it is a novice novices or investors who pursue passive income, the following 11 platforms are worth paying attention to. Hashbeat app: a regulated crypto cloud mining platform that provides free Bitcoin mining rewards, daily payments. If you want to invest in low-risk, high-security, stable returns in cryptocurrency in 2025, Hashbeat app

ABI compatibility in C refers to whether binary code generated by different compilers or versions can be compatible without recompilation. 1. Function calling conventions, 2. Name modification, 3. Virtual function table layout, 4. Structure and class layout are the main aspects involved.

Handling high DPI display in C can be achieved through the following steps: 1) Understand DPI and scaling, use the operating system API to obtain DPI information and adjust the graphics output; 2) Handle cross-platform compatibility, use cross-platform graphics libraries such as SDL or Qt; 3) Perform performance optimization, improve performance through cache, hardware acceleration, and dynamic adjustment of the details level; 4) Solve common problems, such as blurred text and interface elements are too small, and solve by correctly applying DPI scaling.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

C is suitable for processing sensor data due to its high performance and low-level control capabilities. Specific steps include: 1. Data collection: Obtain data through the hardware interface. 2. Data analysis: convert the original data into available information. 3. Data processing: filtering and smoothing processing. 4. Data storage: Save data to a file or database. 5. Real-time processing: Ensure the efficient and low latency of the code.

Installing MySQL on macOS can be achieved through the following steps: 1. Install Homebrew, using the command /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". 2. Update Homebrew and use brewupdate. 3. Install MySQL and use brewinstallmysql. 4. Start MySQL service and use brewservicesstartmysql. After installation, you can use mysql-u
