1.Rodrigues 旋转公式的矩阵形式
例如:
于是我们有任意向量 A 绕着轴n旋转就等同于R * A的结果。
2.世界坐标系转化到相机坐标系
总而言之,只要把相机的右(g叉乘t),上方向(t),g方向按列排放并且在最后一列放上平移的数字就得到了将世界坐标系变换到相机坐标系的旋转变化复合矩阵。
3.正交投影矩阵
将一个立方体,中点平移到原点上,并且将长宽高映射到Range(-1,1)成为一个立方体。
4.透视投影
作业0答案
#include <bits/stdc++.h>
#include "E:\Desktop\Cscript\Computer Graphics\eigen-3.4.0\Eigen\Dense"
using Eigen::MatrixXd;
using Eigen::VectorXd;
using namespace std;
int main() {
Eigen::Matrix3f i;
Eigen::Vector3f p(2.0f, 1.0f, 1.0f);
i << cos(45), -sin(45), 1.0f,
sin(45), cos(45), 2.0f,
0.0f, 0.0f, 1.0f;
Eigen::Vector3f ans = i * p;
cout << ans;
return 0;
}
Output:
作业1:
Eigen::Matrix4f get_model_matrix(float rotation_angle)
{
Eigen::Matrix4f model = Eigen::Matrix4f::Identity();
// TODO: Implement this function
// Create the model matrix for rotating the triangle around the Z axis.
// Then return it.
float angle = rotation_angle * (MY_PI / 180);
Matrix4f i;
i << cos(angle), -sin(angle), 0, 0,
sin(angle), cos(angle), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1;
model = model * i;
return model;
}
Eigen::Matrix4f get_projection_matrix(float eye_fov, float aspect_ratio,
float zNear, float zFar)
{
// Students will implement this function
Eigen::Matrix4f projection = Eigen::Matrix4f::Identity();
// TODO: Implement this function
// Create the projection matrix for the given parameters.
// Then return it.
float tempeye = eye_fov * (MY_PI / 180);
float n = zNear;
float f = zFar;
Matrix4f i;
i << 1 / (tan(tempeye / 2) * aspect_ratio), 0, 0, 0,
0, 1 / tan(tempeye / 2), 0, 0,
0, 0, (f + n) / (f - n), -2 * f * n / (f - n),
0, 0, 1, 0;
projection = i * projection;
return projection;
}