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.
//my code start
rotation_angle=rotation_angle/180*MY_PI;
model<<cos(rotation_angle),-sin(rotation_angle),0,0,
sin(rotation_angle),cos(rotation_angle),0,0,
0,0,1,0,
0,0,0,1;
//end
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.
//my code
Eigen::Matrix4f Mortho_translate=Eigen::Matrix4f::Identity();
Eigen::Matrix4f Mortho_scale=Eigen::Matrix4f::Identity();
Eigen::Matrix4f Mo=Eigen::Matrix4f::Identity();
Eigen::Matrix4f Mpo=Eigen::Matrix4f::Identity();
float r,l,t,b;
float halfAngle=eye_fov/2/180*MY_PI;
t=std::tan(halfAngle)*zNear;
r=aspect_ratio*t;
l=-r;
b=-t;
Mortho_translate<<1,0,0,-(r+l)/2,
0,1,0,-(t+b)/2,
0,0,1,-(zNear+zFar)/2,
0,0,0,1; //ping yi
Mortho_scale<<2/(r-l),0,0,0,
0,2/(t-b),0,0,
0,0,0,2/(zNear-zFar),
0,0,0,1; //suo fang
Mo=Mortho_scale*Mortho_translate;
Mpo<<zNear,0,0,0,
0,zNear,0,0,
0,0,zNear+zFar,-zNear*zFar,
0,0,1,0;
projection=Mo*Mpo;
//end
return projection;
}
GAMES 101 Assignment 1