大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
#include "mainwindow.h"
#include <QApplication>
#include "eigen3/Eigen/Core"
#include "eigen3/Eigen/Dense"
#include <cmath>
#include <iostream>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
float value = 4.0;
float angle = 90.0;
float radian = 3.141593;
//平方根
std::cout <<"sqrt:"<< std::sqrt(value) << std::endl;
//反余弦--算出来弧度
std::cout <<"acos -1:"<< std::acos(-1) << std::endl;
//角度求正弦
std::cout <<"sin angle:"<< std::sin(angle/180.0*acos(-1)) << std::endl;
//弧度求正弦
std::cout <<"sin radian:"<< std::sin(radian/2.0) << std::endl;
//定义一个vector
Eigen::Vector3f v1(1.0f,0.0f,0.0f);
std::cout <<"Vector3f:" << v1 << std::endl;
Eigen::Vector3f v2(0.0f,1.0f,0.0f);
//点乘
std::cout <<"Vector3f dot:" << v1.dot(v2) << std::endl;
std::cout <<"Vector3f dot:" << v2.dot(v1) << std::endl;
//叉乘
std::cout <<"Vector3f cross:" << v1.cross(v2) << std::endl;
std::cout <<"Vector3f cross:" << v2.cross(v1) << std::endl;
Eigen::Vector3f v3(5.0f,0.0f,0.0f);
std::cout <<"Vector3f normalized:" << v3.normalized() << std::endl;
//定义一个matrix
Eigen::Matrix3f m = Eigen::Matrix3f::Identity();//生成一个单位矩阵
std::cout <<"Matrix3f Identity:"<< m << std::endl;
m << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0;
std::cout <<"Matrix3f:"<< m << std::endl;
//获取矩阵的第二行第二列
std::cout <<"Matrix3f(2,2):"<< m(1,1) << std::endl;
//矩阵转置
std::cout <<"Matrix3f transpose:"<< m.transpose() << std::endl;
//矩阵共轭
std::cout <<"Matrix3f conjugate:"<< m.conjugate() << std::endl;
//矩阵共轭转置
std::cout <<"Matrix3f adjoint:"<< m.adjoint() << std::endl;
return a.exec();
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/180381.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...