当前位置:网站首页>【Games101】Transformation
【Games101】Transformation
2022-06-30 00:47:00 【Missnish】
- Linear algebra related
- Vector point multiplication → Obtain direction
- Vector cross product → Get around & domestic and foreign
- linear transformation : A transformation that keeps the mesh parallel and equidistant
The properties of linear transformation :
- All the lines are still straight ( Including diagonals )
- The origin is still the origin , No movement
- How do we understand Transformation( Transformation )?
ordinary , We can understand it as a series of steps , Through these steps , It can realize the transformation from three-dimensional space to two-dimensional image .

One 、 A two-dimensional / Three dimensional transformation
The zoom (Scale)

symmetry (Reflection)

shear (Shear)

rotate (Rotation)

Affine transformation = linear transformation + Translation transformation

Homogeneous coordinates :
because 2D The transform has no offset , So it's impossible to say 2D Pan operation , The main function of homogeneous coordinates is to introduce offset , Translate transform (Translate) Unified classification 2D Transformation , You don't want the translation transform to be different from the others 2D Transformation .
At the same time, homogeneous coordinates can distinguish points from vectors , According to the translation invariance of the vector , Vectorial w Shaft for 0, Dot w Shaft for 1.

With homogeneous coordinates , The translation transformation is expressed as follows :

Combination transformation
(1) Properties based on rotation calculation ( Rotate around the origin ), When multiple transformation matrices are calculated, they are usually rotated first and then translated .


(2) For an image that is not at the origin , How to perform rotation transformation ?
First, translate the image to the origin , The original position will be translated after the transformation operation .

Summary of basic transformation matrix

Two 、MVP Transformation
MVP The transformation consists of three transformations , namely Model Transformation、View / Camera Transformation、Projection Transformation.

Model transformation (placing objects)
The objects in the world coordinate system , Using a change matrix, their vertex coordinates are transformed from local to local Local Coordinate system ( relative ) Switch to the world Global Coordinate system ( absolute ), the DCC Model coordinates in are converted to model coordinates in the engine .
View transformation (placing camera)
Put the world coordinate system ( The center of the world is the origin ) To the camera coordinate system ( Camera position is the origin ), Realize the transformation from the third perspective to the first perspective .
(1) How do we define a camera ?
We define the position of the camera as
, Orientation is defined as
, Up ( It's like an antenna ) Defined as
.

(2) How to achieve M→V Transformation ?
Pan the camera to the origin ,
、
、
Rotate to
、
、
.
among ,
/
It's the camera up ( The antenna ),
/
Is the viewing direction of the camera , Cross multiply to get
/
.
thus
、
、
The model space coordinate system is converted to
、
、
Observation space coordinate system .

(3) How to calculate the target rotation matrix ?
Rotation matrix solution : First find the rotation matrix from the origin to the camera , Then inverse the rotation matrix from the camera to the origin .

notes : The inverse of the rotation matrix = Transpose matrix of rotation matrix
Projection transformation
The space observed by the camera is usually a visual cone , The projection transformation transforms the viewing cone into a 1×1×1 Standard Cube , To facilitate subsequent operations .
There are two forms of projection transformation , Perspective projection (Perspective Projection) And orthogonal projection (Orthographic Projection).

(1) Orthographic projection (Orthographic Projection)
How to understand orthogonal projection ?

We set the space of all objects as a cube , Translate and zoom the cube , It becomes a point centered on the origin 1×1×1 Standard Cube .

The transformation matrix is as follows :

(2) Perspective projection (Perspective Projection)
We think that perspective projection presents a phenomenon of near large and far small , That is, with most cameras 、 The imaging principle of the human eye is the same .
How to realize perspective projection ?
- First convert perspective projection to orthogonal projection , That is to realize the extrusion from the far plane to the near plane
- Do another orthogonal projection

How to realize extrusion from far plane to near plane ?
First, get the screen aspect ratio , And then calculate through similar triangles .


The resulting matrix is as follows :

Reference resources :
GAMES101- Introduction to modern computer graphics - Yan Lingqi _ Bili, Bili _bilibili
边栏推荐
- 如何在IDEA中自定义模板、快速生成完整的代码?
- [PHP] PHP variable memory release
- 清洁、对话、带娃,扫地机摆脱“人工智障”标签
- MySQL advanced 2
- Time does not spare
- 岁月匆匆那年
- 阿于的彩虹桥
- Briefly: how are fragments communicated?
- Interviewer: how to solve the problem of massive requests for data that does not exist in redis, which affects the database?
- Nested call and chained access of functions in handwritten C language
猜你喜欢

Crmeb SMS for program configuration of knowledge payment system

Bytek suffered a disastrous defeat in the interview: he was hanged on one side, but fortunately Huawei pushed him in, and he got an offer on three sides

科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头

外包干了三年,废的一踏糊涂...

TwinCAT 3 el7211 module controls Beifu servo

Exercise "product": self made colorful Prompt string display tool (for loop and if condition judgment)

Too voluminous ~ eight part essay, the strongest king of interview!

Top performance version 2 reading notes (IV) -- memory monitoring

太卷了~ 八股文,面试最强王者!

Antd - tree structure: default deployment node attribute failure - Basic promotion
随机推荐
Which direction of network development is better? Data communication engineer learning path sharing
What is the essential difference between get and post requests?
Ml: introduction to confidence interval (the difference and relationship between precision / accuracy / accuracy), use method, and detailed introduction to case application
Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
【PHP】php压测,报错:通常每个套接字地址(协议/网络地址/端口)只允许使用
字节面试惨遭滑铁卢:一面就被吊打,幸得华为内推,三面拿到offer
字符串之间的比较之 localeCompare
Flask web minimalist tutorial (III) - Sqlalchemy (part a)
阿于的彩虹桥
间歇采样转发干扰
MySQL advanced 1
2022年最新最详细IDEA关联数据库方式、在IDEA中进行数据库的可视化操作(包含图解过程)
Some thoughts on life
Solve the problem of repairing Visual Basic exceptions with excel/wps plug-in of choice financial terminal
阿洛觉得自己迷茫
Modbus TCP RTU protocol chart
Time does not spare
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network
Briefly: how are fragments communicated?
优秀的测试/开发程序员与普通的程序员对比......