天天看點

GAMES101學習筆記(Lecture1-2)

該筆記基于闫令琪大神的GAMES101課程及課後作業總結而成 

目錄

​​學習過程中遇到的一些詞 ​​

​​線代基礎​​

​​Eigen庫的用處​​

​​矩陣/向量的練習: ​​

GAMES101學習筆記(Lecture1-2)

學習過程中遇到的一些詞 

Geometrically: Parallelogram law & Triangle law

幾何:平行四邊形定律和三角形定律

Algebraically: Simply add coordinates

代數上:簡單地添加坐标

usually orthogonal unit

通常正交單元

Cartesian Coordinates

笛卡爾坐标

Dot product

點積

Cross product

交叉積

Orthonormal bases and coordinate frames

正交基與坐标架構

Decompose a vector

分解向量

dual matrix of vector a

向量a的對偶矩陣

homogenous coordinate 

齊次坐标

線代基礎

點乘可分解向量以及判斷向量之間接近or遠離

叉乘可判斷方位

點乘

GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)

叉乘求得的結果垂直于兩個原始向量,是以常用于求法線, 是以三維軟體會提供翻轉法線的功能 opengl永遠是右手系,DirectX經常是左手系

GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)

a在b的左側的意思是,a經過不大于180°的逆時針旋轉可以與b的方向一緻,右側同理,方向變為順時針

點在所有向量左側或在所有向量左側,就是多邊形内部

GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)
GAMES101學習筆記(Lecture1-2)

Eigen庫的用處

​​Eigen

GAMES101學習筆記(Lecture1-2)

https://eigen.tuxfamily.org/index.php?title=Main_Page​​

GAMES101學習筆記(Lecture1-2)

 ​​Eigen: Matrix and vector arithmetic

GAMES101學習筆記(Lecture1-2)

https://eigen.tuxfamily.org/dox/group__TutorialMatrixArithmetic.html​​

矩陣/向量的練習: 

#include <iostream>
#include <Eigen/Dense>

using namespace Eigen;

int main()
{
    std::cout << "Example of cpp :\n";
    float a = 1.0, b = 2.0;
    std::cout << a << std::endl;
    std::cout << a / b << std::endl;
    std::cout << std::sqrt(b) << std::endl;//√2
    std::cout << std::acos(-1) << std::endl;//arccos(-1)
    std::cout << std::sin(30.0 / 180.0 * acos(-1)) << std::endl;//sin(30°)

    Matrix2d a;
    a << 8, 2,
        2, 1;
    MatrixXd b(2, 2);
    b << 4, 1,
        1, 4;
    std::cout << "a =\n" << a << std::endl;
    std::cout << "b =\n" << b << std::endl;
    std::cout << "a + b =\n" << a + b << std::endl;
    std::cout << "a - b =\n" << a - b << std::endl;
    std::cout << "Do: a += b;" << std::endl;
    a += b;
    std::cout << "Now: a =\n" << a << std::endl;

    MatrixXf i(3,3), j(3,3);
    i << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0;
    j << 2.0, 3.0, 1.0, 4.0, 6.0, 5.0, 9.0, 7.0, 8.0;
    std::cout << "i * j =\n" << i*j << std::endl;

    Vector3d v(1, 2, 3);
    Vector3d w(1, 2, 4);
    std::cout << "v =\n" << v << std::endl;
    std::cout << "w =\n" << w << std::endl;
    std::cout << "v - 2 * w =\n" << v - 2 * w << std::endl;

    MatrixXf c(2, 3); 
    c << 1, 2, 3, 4, 5, 6;
    std::cout << "Here is the initial matrix c:\n" << c << std::endl;

    c.transposeInPlace();
    std::cout << "and after being transposed:\n" << c << std::endl;
}      
Example of cpp :
1
0.5
1.41421
3.14159
0.5
a =
8 2
2 1
b =
4 1
1 4
a + b =
12  3
 3  5
a - b =
 4  1
 1 -3
Do: a += b;
Now: a =
12  3
 3  5
i * j =
 37  36  35
 82  84  77
127 132 119
v =
1
2
3
w =
1
2
4
v - 2 * w =
-1
-2
-5
Here is the initial matrix c:
1 2 3
4 5 6
and after being transposed:
1 4
2 5
3 6      
下一篇: 雲存儲價格

繼續閱讀