Preface:
I just want 放洋屁,and then learn graphics. So,This essay is born.
I will show you the whole process of my study,Including the bugs I created.
Cool lets begin!
Download:
BaiduNetworkDisk:from bilibili comment
https://pan.baidu.com/s/1ttFTBF_Bk7eN6X3DE4ca0Q?pwd=void
Open pdf files and you will see the explanation in Chinese.
Lets open homework 0!
DO:
I'll spare you the procedure for configuring the virtual machine.
then here are some bugs and problems I've had:
Cannot drag files:
choose a disk file and find:VBoxGuestAdditions.iso
choose drag bothway:
then see this:
VirtualBox虚拟机与主机之间复制粘贴设置以及文件拖拽_vm virtualbox怎么互拖文件-CSDN博客
but paste board sharing problem is not solved!!
Distinguish between points and vectors in 3D:
Scale and Translation:
Rotation:
You just need to apply the formula!
Code:
#include<cmath>
#include<eigen3/Eigen/Core>
#include<eigen3/Eigen/Dense>
#include<iostream>
//acos(-1)==pi#define PI std::acos(-1)
int main(){// Basic Example of cppstd::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;std::cout << std::acos(-1) << std::endl;std::cout << std::sin(30.0/180.0*acos(-1)) << std::endl;// Example of vectorstd::cout << "Example of vector \n";// vector definitionEigen::Vector3f v(1.0f,2.0f,3.0f);Eigen::Vector3f w(1.0f,0.0f,4.0f);// vector outputstd::cout << "Example of output \n";std::cout << v << std::endl;// vector addstd::cout << "Example of add \n";std::cout << v + w << std::endl;// vector scalar multiplystd::cout << "Example of scalar multiply \n";std::cout << v * 3.0f << std::endl;std::cout << 2.0f * v << std::endl;// Example of matrixstd::cout << "Example of matrix \n";// matrix definitionEigen::Matrix3f i,j;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;// matrix outputstd::cout << "Example of output \n";std::cout << i << std::endl;// matrix add i + j// matrix scalar multiply i * 2.0// matrix multiply i * j// matrix multiply vector i * vEigen::Vector3f p(2.0,1.0,1.0);Eigen::Matrix3f T,R;//all angles in the future will be radian systemfloat angle=45.0/180.0*PI;//write rotation around z axis R<<std::cos(angle),-std::sin(angle),0.0,std::sin(angle),std::cos(angle),0.0,0.0, 0.0, 1.0;//translate:T<<1.0,0.0,1.0,0.0,1.0,2.0,0.0,0.0,1.0;std::cout<<"outputTRP"<<std::endl;//multiply from right to leftstd::cout<<T*R*p<<std::endl;return 0;
}