网课:GAMES101-homework pa0

作业1还是挺简单的,把课上一些基本的概念写成代码即可。
在这里插入图片描述

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

int main(){

    // Basic Example of cpp
    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;
    std::cout << std::acos(-1) << std::endl;
    std::cout << std::sin(30.0/180.0*acos(-1)) << std::endl;
    std::cout << "test the precision of pi:" << std::acos(-1.0) << std::endl;

    // Example of vector
    std::cout << "Example of vector \n";
    // vector definition
    Eigen::Vector3f v(1.0f,2.0f,3.0f);
    Eigen::Vector3f w(1.0f,0.0f,0.0f);
    // 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.0f << std::endl;
    std::cout << 2.0f * v << std::endl;

    // Example of matrix
    std::cout << "Example of matrix \n";
    // matrix definition
    Eigen::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 output
    std::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 * v
    // homework pa0
    Eigen::Vector3f p,res;
    p << 2,1,1;
    Eigen::Matrix3f rotation,translation;
    translation << 1,0,1,0,1,2,0,0,1;
    rotation << std::cos(45.0/180.0*acos(-1)),-1*std::sin(45.0/180.0*acos(-1)),0,
                std::sin(45.0/180.0*acos(-1)), std::cos(45.0/180.0*acos(-1)),0,
                0,0,1;
    res = translation*rotation*p;
    std::cout << "this is the res point:" << std::endl;
    std::cout << res << std::endl;

    return 0;
}

结果如下:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
root:$6$RMpgG8z.$GrGzDK0J1/uXc/Z2WIp6WgIYEB6Bi/Sw2aCc86U2E.BK80mszROf4K1ZB172DOQzgRb6U/2jGPh/8rwXQsbM3/:17277:0:99999:7::: daemon:*:17272:0:99999:7::: bin:*:17272:0:99999:7::: sys:*:17272:0:99999:7::: sync:*:17272:0:99999:7::: games:*:17272:0:99999:7::: man:*:17272:0:99999:7::: lp:*:17272:0:99999:7::: mail:*:17272:0:99999:7::: news:*:17272:0:99999:7::: uucp:*:17272:0:99999:7::: proxy:*:17272:0:99999:7::: www-data:*:17272:0:99999:7::: backup:*:17272:0:99999:7::: list:*:17272:0:99999:7::: irc:*:17272:0:99999:7::: gnats:*:17272:0:99999:7::: nobody:*:17272:0:99999:7::: systemd-timesync:*:17272:0:99999:7::: systemd-network:*:17272:0:99999:7::: systemd-resolve:*:17272:0:99999:7::: systemd-bus-proxy:*:17272:0:99999:7::: _apt:*:17272:0:99999:7::: mysql:!:17272:0:99999:7::: epmd:*:17272:0:99999:7::: Debian-exim:!:17272:0:99999:7::: uuidd:*:17272:0:99999:7::: rwhod:*:17272:0:99999:7::: redsocks:!:17272:0:99999:7::: usbmux:*:17272:0:99999:7::: miredo:*:17272:0:99999:7::: Debian-snmp:!:17272:0:99999:7::: ntp:*:17272:0:99999:7::: stunnel4:!:17272:0:99999:7::: sslh:!:17272:0:99999:7::: rtkit:*:17272:0:99999:7::: postgres:*:17272:0:99999:7::: dnsmasq:*:17272:0:99999:7::: messagebus:*:17272:0:99999:7::: iodine:*:17272:0:99999:7::: arpwatch:!:17272:0:99999:7::: couchdb:*:17272:0:99999:7::: avahi:*:17272:0:99999:7::: sshd:*:17272:0:99999:7::: colord:*:17272:0:99999:7::: saned:*:17272:0:99999:7::: speech-dispatcher:!:17272:0:99999:7::: pulse:*:17272:0:99999:7::: king-phisher:*:17272:0:99999:7::: Debian-gdm:*:17272:0:99999:7::: dradis:*:17272:0:99999:7::: beef-xss:*:17272:0:99999:7::: xrdp:!:17472:0:99999:7::: lightdm:*:17472:0:99999:7::: ctf:$6$d1Y17YhS$P1G.pKFO6VKvKx.y0H7nP5kXAHUAhj6hYroEA.ThT1/kErw37IhVclt.UWCFXrfq/sEZk1jhb52KlPWidJKpp0:17473:0:99999:7:::
最新发布
07-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值