Setting up a VM

This article is about yan Lingqi’s Games101 homework and the learning process. The website is games-cn.org/forums/foru…

1 VM environment setting up

1.1 Installing a VM

Here we use the Oracle VM VirtualBox virtual machine.

  • If you are using Windows, you can direct download download.virtualbox.org/virtualbox/… After downloading, follow instructions to complete the installation.
  • If you use Mac OS system, you can directly download download.virtualbox.org/virtualbox/… After downloading, follow instructions to complete the installation.
  • If you use the Linux kernel system, you can check www.virtualbox.org/wiki/Linux_… And follow the instructions to complete the installation.

1.2 Downloading a Virtual Disk

Virtual hard disk file download address for cloud.tsinghua.edu.cn/f/103133da1… . GAMES101_Ubuntu 18.04.2 (64bit).rar. Unpack the GAMES101_Ubuntu 18.04.2 (64bit).vdi.

1.3 Configuring a VM

Open the Virtual Box, click create, set the vm type to Linux and version to ubuntu-64 bit, set the vm memory size to 2GB, and select the existing Virtual hard disk file. Set it to GAMES101_Ubuntu 18.04.2 (64bit).vdi and click Create to complete the vm configuration.

Then you can use the created VIRTUAL machine. Select the newly created virtual machine and click the startup button in the upper right to start the virtual machine. The password of Ubuntu isIlovegraphics(Note the capital I).

1.4 Installing Guest Additions

After entering the system, click the device in the upper menu and click Install enhanced functions, as shown in the picture below. After the installation is complete, restart the virtual machine system to complete the installation of Guest Additions

If the above method fails, you can use CTRL + Alt + T to call out the terminal, Run the following command to install Guest Additions sudo mkdir -p /media/cdrom sudo mount -t auto /dev/cdrom /media/cdrom/ CD /media/cdrom/ sudo sh VBoxLinuxAdditions.run

There you go

Then restart the VM system

1.5 Transmission and editing of operation framework

There are many ways to import and export job frames, but I’ll mention just one. Once you have downloaded the job frame from your host, drag it directly into the virtual machine system. You need to enable the drag and drop function of the Virtual Box: After logging in to the VM system, click the device in the upper menu and set the drag and drop function to bidirectional.

Drag in the folder 📂

2. Operation framework description

This section will be shown in the sample program main.cpp

2.1 Precautions for using Elgen Library

Eigen is a library of linear algebra operations used in this course. The official documentation is eigen.tuxfamily.org

2.2 the header file

As shown in the sample program main.cpp, eigen needs to introduce an additional header file <eigen3/ eigen /Core>

#include <eigen3/Eigen/Core>
Copy the code

2.3 Vectors and matrices

About this part, please read the official document eigen.tuxfamily.org/dox/group__ matrix part… To gain a fuller, clearer understanding. Install the plugin and run the results

    // Example of vector
    std::cout << "Example of vector \n";
    // vector definition
    Eigen :: Vector3f v(1.0 f.2.0 f.3.0 f);
    Eigen :: Vector3f w(1.0 f.0.0 f.0.0 f);
    // vector output
    std::cout << "Example of output \n";
    std::cout << v << std::endl;
    // vector add
    std::cout << "Example of add \n";
    std::cout << v + w << std::endl;
    // vector scalar multiply
    std::cout << "Example of scalar multiply \n";
    std::cout << v * 3.0 f << std::endl;
    std::cout << 2.0 f * v << std::endl;
Copy the code

The above example using Vector shows how to define a three-dimensional floating point Vector and output, add, subtract, multiply,Please explore the use of dot product according to the form of number product and vector dot product

3 the homework

Given a point P=(2,1), rotate the point 45â—¦ counterclockwise around the origin first and then translate it (1,2) to calculate the coordinates of the transformed point (homogeneous coordinates are required for calculation).

#include <cmath>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Dense>
#include <iostream>

int main(a){
    Eigen::Vector3d test(2.0 f.1.0 f.1.0 f);
    Eigen::Matrix3d rota;
    Eigen::Matrix3d tran;
    double theta = 45.0/180.0*M_PI;
    rota << cos(theta), 1.0*sin(theta), 0.sin(theta), cos(theta), 0.0.0.1;
    tran << 1.0.1.0.1.2.0.0.1;
    test = tran * rota * test;
    std::cout << test << std::endl;
    std::cout <<  "After rotation and transform the point sits at " 
        << test[0] < <"," << test[1] << std::endl;
    return 0;
}
Copy the code