CPT205 W2
This’s the note of CPT205 W2.
The topics for this week:
- Computer representation of objects
- Cartesian co-ordinate system
- Points, lines and angles
- Trigonometry 三角函数
- Vectors (unit vector) and vector calculations (addition, subtraction, scaling, dot product, cross product) 矢量和矢量计算
- Matrices (dimension, transpose, square/symmetric/identity, inverse) and matrix calculations (addition, subtraction, multiplication) 矩阵和矩阵计算
因为矩阵的知识快忘光了,所以矩阵的部分写的比较多。
Lecture
Computer representation of objects
Cartesian co-ordinate system
都是笛卡尔平面直角坐标系的知识,不会的建议重开。
Points, lines and angles
同上。
Trigonometry
同上。
Vectors
同上。
Matrices
- Techniques for applying transformations use matrices. 应用变换的技术使用矩阵。
- A matrix is simply a set of numbers arranged in a rectangular format. 矩阵是一组按矩形形式排列的数字。
- Each number is known as an element. 每个数字都是一个元素。
- Capital letters are used to represent a matrix. 用大写字母表示矩阵。
- Bold letters when printed (M), or underlined when written. 打印时加粗或下划线。
- A matrix has dimensions that refer to the number of rows and the number of columns it has. 矩阵的维数指的是它的行数和列数
Dimensions of matrices
The dimensions of Matrix are (x * y). x is the number of rows in matrix and y is the columns.
$$
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{bmatrix}
$$
The dimensions of this matrix are (2*3).
Transpose matrix
When a matrix is rewritten so that its rows and columns are interchanged, then the resulting matrix is called the transpose of the original. 当一个矩阵被改写使它的行和列互换时,得到的矩阵叫做原矩阵的转置。
The original A:
$$
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{bmatrix}
$$
The transpose matrix of A:
$$
\begin{bmatrix}
1 & 4 \\
2 & 5 \\
3 & 6 \\
\end{bmatrix}
$$
Square and symmetric matrices
- A square matrix is matrix where the number of rows equals the number of columns. 行列数量相同的是方阵。
- A symmetric matrix is a square matrix where the rows and columns are such that its transponse is the same as the original matrix. 对角线对称的方阵是对称矩阵。
Identity matrices
An identity matrix, I is a square matrix with zeros everywhere except its diagonal elements which have a value of 1. 单位矩阵就是对角线是1,剩下的都是0的方阵。
Adding matrices
- Matrices A and B may be added if they have the same dimensions.
- That is, the corresponding elements may be added to yield a resulting matrix.
- The sum is commutative, i.e. A + B = B + A 加法交换律
Subtracting matrices
Matrix B may be subtracted from matrix A if they have the same dimensions, i.e. the corresponding elements of B may be subtracted from those of A to yield a resulting matrix.
The result is not commutative. Reversing the order of the matrices yields different results, i.e. A - B ≠ B -A ⚠️减法🈚️交换律!
Multiplying matrices
- By a constant
- By a matrix - The rule for multiplying one matrix to another is simple: if the number of columns in the first matrix is the same as the number of rows in the second matrix, the multiplication can be done. 也就是必须要是(x * y)&(y * z),计算结果是(x * z)。
Matrix multiplication is not commutative. Reversing the order of the matrices yields different results. ⚠️矩阵的乘法也是没有交换律的!交换相乘的两个矩阵的位置会产生不同的结果。
Inverse matrices
If two matrices A and B, when multiplieid together, results in an indentity matrix I, then matrix A is the inverse of matrix B and vice versa, i.e.
$$A * B = B * A = I$$
$$A = B^{-1} and B = A^{-1}$$
两个矩阵相乘是一个单位矩阵那这两个矩阵就是逆矩阵。
Lab
The tutorial explains the C/C++ basics that will be used in CPT205 Computer Graphics.
跟着lab做问题不大,注意一个cpp的project中只有可以有一个main
方法,这是和py不一样的地方。
学校给的那个lab代码需要引入math
才可以正常操作。
引入库的时候需要手动输入,复制粘贴的时候会出现无法读取的问题 #include <GL/freeglut.h>
1 | #define FREEGLUT_STATIC |
References
- XJTLU CPT205 slides (Week2)