当前位置:网站首页>Personal notes of graphics (3)
Personal notes of graphics (3)
2022-07-07 16:30:00 【qq_ fifty-seven million two hundred and fifty-one thousand thre】
View transformation :
The main purpose of learning transformation is to turn a three-dimensional object into a two-dimensional picture
How to take photos (1. Put the model in place 2. Put the camera away 3. Taking pictures )

(MVP Transformation )
//----------------------------------------------------------------------------------------------------//
Change of perspective :
There are two ways 1. Construct a matrix from world space to observation space 2. Pan the entire viewing space , Place the camera at the origin , At this time, the coordinates of the object are the relative positions in the observation space Here we take the second approach
ps: The camera and the object it sees move relative
pps: The purpose of camera transformation is to get the relative positions of all visible objects and cameras , How to get ? A very intuitive step , We move the object with the camera ( The matrix obtained by restoring the camera to the origin is multiplied by the model ), If you can put the coordinate axis of the camera ( Assuming that u,v,w Respectively corresponding to x,y,z) Move to standard x,y,z Axis , Then the coordinates of the object at this time are not naturally relative coordinates !
Essentially, the operation is divided into two steps ,1. Move to origin ,2. Rotate the axis of the camera to xyz Axis
![]()
There are some things that need to be said :
In the observation space , The camera is at the origin , Observe the coordinate axis of space +x Point to the right ,
+y Above ,+z In the rear
First step : Establish the camera coordinate system


The second step : After successfully establishing the camera coordinate system , How to move it to the original world coordinate system ?

( Note that this is not a linear transformation before translation But first translation and then linear transformation )
( Rotating an arbitrary axis to a normalized axis is not easy to write , But the reverse is easy to write , such as X Axis (1,0,0) Rotating to a certain axis is easy to write )
![]()
Here the teacher directly wrote such an inverse matrix ( The derivation process can be seen by yourself ), Suppose you give a vector (1,0,0,0) Multiply by this matrix and you will get 
It's exactly the same ![]()


( The matrix of the origin transformation camera is derived directly above , So directly invert this matrix to get the last matrix we need )
Tips : Inside the spin , The inverse matrix of rotation is equal to that of rotation matrix 【 Transposition 】

pps( Finally applied to objects )
//----------------------------------------------------------------------------------------------------//
Projection transformation :
( The second picture is perspective The first picture is orthogonal )

The size of near big far small and near far are the same

Orthographic projection :
Put the camera at the origin here , the -z Look in the direction , The upward direction of the camera is y, At this time z Throw it away and get an orthogonal image

Throw away z after All objects are x and y In the plane , It doesn't matter at this time x and y How big is the plane formed , We all map him to -1 To 1 In the cube of
![]()
( The purpose of mapping is to prepare for the next step of rasterization )
For orthogonal projection , Will turn any shape into such a standard body , The operation steps are as follows
1. First move to the origin 2. Zoom all the points ( shrinkage )

x Left and right on the axis (l r)
y Up and down on the shaft (b t)
z Far and near on the axis (f n)
![]()
for instance
The rightmost matrix represents l r Move the midpoint of to the origin
The matrix next to represents mapping to x On the shaft And the left and right add up to 2
2. Perspective projection :
Parallel lines are not parallel

The following is an example of multiplying any point by any number , The final point is the original point ( Divided by w Remember that nature ?) Taking what is not taking Let's take a z

The difference between orthographic projection and perspective projection Both far and near But the extended lines are inconsistent ( Parallel not parallel )

The perspective projection can be split in two :
1. First squeeze the perspective projection ( Compress ) Form a cube like a near plane ( The near plane remains unchanged ,z No change , The center does not change )
2. Then do orthogonal projection ( Move first And then compress it into -1 To 1 The cube )
First step , extrusion ( hold y Squeeze to y')

Similar triangle rule The distance between the near plane and the far plane == The height of the near plane is higher than that of the far plane

Empathy ,x I know

At this point, we squeeze the matrix x and y I have got it however z Still don't know

It is also known that the result of multiplying a point by a constant is still equal to this point Then let's multiply by z

So the final equation is equal to

Some point (xyz1) Dot multiplying a matrix must be equal to the above matrix So we can guess some numbers ( first line :x*n)

Now that's all Z I don't know. , But we summarized the rules :
1. No point changes in the near plane
2. Far plane z No change
So according to the law of the near plane, we can get


So according to the law of the far plane ( The center of the far plane (00f) It is the same. ) You can get

So finally :

Then do the orthogonal projection to get the perspective projection
//----------------------------------------------------------------------------------------------------//
When you know a vector , And obtain a transformation matrix ( translation , rotate , Zoom or operate together, etc ) when ,
Multiplication represents the corresponding transformation of this vector ( translation , rotate , Zoom or operate together, etc )
1. Transformation from model space to world space : According to the model Transfrom Find the transformation matrix with world space
2. Transform vertices from world space to observation space ( Camera space , Not two-dimensional space ): Similarly, according to the camera Transfrom Find the transformation matrix between camera space and world space ( We need to pay attention to The camera space uses the right-hand coordinate system , So the matrix should be right z The component is reversed )
3. From observation space to clipping space : Involves two projections ( Orthographic projection , Perspective projection Perspective has the law of near big and far small , Orthogonality is the same size far and near ),
边栏推荐
- Power of leetcode-231-2
- Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
- laravel构造函数和中间件执行顺序问题
- Have fun | latest progress of "spacecraft program" activities
- 47_ Contour lookup in opencv cv:: findcontours()
- Laravel service provider instance tutorial - create a service provider test instance
- 分步式监控平台zabbix
- PHP实现微信小程序人脸识别刷脸登录功能
- Shader basic UV operations, translation, rotation, scaling
- Opportunity interview experience summary
猜你喜欢

Spark Tuning (III): persistence reduces secondary queries
![[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3](/img/8f/ca9ab042916f68de7994d9f2124da9.jpg)
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3

What about the pointer in neural network C language

Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition

Vs tool word highlight with margin
![[vulnhub range] thales:1](/img/fb/721d08697afe9b26c94fede628c4d1.png)
[vulnhub range] thales:1

Tragedy caused by deleting the console statement

You Yuxi, coming!

HAVE FUN | “飞船计划”活动最新进展

Leetcode-231-2的幂
随机推荐
Laravel changed the session from file saving to database saving
模拟Servlet的本质
Performance measure of classification model
23. 合并K个升序链表-c语言
【Vulnhub靶场】THALES:1
Record the migration process of a project
分类模型评价标准(performance measure)
How to query the data of a certain day, a certain month, and a certain year in MySQL
Markdown formula editing tutorial
URL和URI的关系
121. 买卖股票的最佳时机
PHP实现微信小程序人脸识别刷脸登录功能
How to determine whether the checkbox in JS is selected
Laravel5.1 Routing - routing packets
markdown公式编辑教程
AutoLISP series (1): function function 1
【C 语言】 题集 of Ⅹ
Iptables only allows the specified IP address to access the specified port
Shader_ Animation sequence frame
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是