Home Backend Development C++ Explain the Donuts as Old as Ears Part 3

Explain the Donuts as Old as Ears Part 3

Apr 04, 2025 am 08:18 AM
c language cos Why

Explain the Donut as Old as Ear 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};
Copy after login

java language

 singlerow circle = new singlerow(2 math.cos(theta), math.sin(theta), 0);
Copy after login

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)
);
Copy after login

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}};
Copy after login

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);
Copy after login

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);
Copy after login

We will make recinz, which will be the countdown of nz 5 (distance from camera)

 float recinz = 1 / (spinningdonut.a3 5);
Copy after login
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;
Copy after login

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
Copy after login

To print it with brightness, we will create an array of characters from the lowest to the highest brightness

 char charopts[] = ".,-~:;=!*#$@";
Copy after login

or

 char[] charopts = {'.', ',', '-', '~', ':', ';', '=', '!', '*', '#', '$', '@'};
Copy after login

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;
}
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1672
14
PHP Tutorial
1277
29
C# Tutorial
1257
24
Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Apr 21, 2025 am 08:57 AM

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.

Hashbeat App: The highest regulated crypto cloud mining platform in 2025 with free Bitcoin mining rewards and daily spending Hashbeat App: The highest regulated crypto cloud mining platform in 2025 with free Bitcoin mining rewards and daily spending Apr 21, 2025 pm 06:21 PM

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

How to understand ABI compatibility in C? How to understand ABI compatibility in C? Apr 28, 2025 pm 10:12 PM

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.

How to handle high DPI display in C? How to handle high DPI display in C? Apr 28, 2025 pm 09:57 PM

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.

Steps to add and delete fields to MySQL tables Steps to add and delete fields to MySQL tables Apr 29, 2025 pm 04:15 PM

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.

What is the difference between php framework laravel and yii What is the difference between php framework laravel and yii Apr 30, 2025 pm 02:24 PM

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.

How to process sensor data in C? How to process sensor data in C? Apr 28, 2025 pm 10:00 PM

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.

Detailed explanation of the installation steps of MySQL on macOS system Detailed explanation of the installation steps of MySQL on macOS system Apr 29, 2025 pm 03:36 PM

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

See all articles