eigen库的优缺点_简单介绍一种你在家中使用过的工具

#include "mainwindow.h"
#include <QApplication>
#include "eigen3/Eigen/Core"
#include "eigen3/Eigen/Dense"
#include <cmath>
#include <iostream>
int mainint argc, char *argv[])
{ 

QApplication aargc, argv);
float value = 4.0;
float angle = 90.0;
float radian = 3.141593;
//平方根
std::cout <<"sqrt:"<< std::sqrtvalue) << std::endl;
//反余弦--算出来弧度
std::cout <<"acos -1:"<< std::acos-1) << std::endl;
//角度求正弦
std::cout <<"sin angle:"<< std::sinangle/180.0*acos-1)) << std::endl;
//弧度求正弦
std::cout <<"sin radian:"<< std::sinradian/2.0) << std::endl;
//定义一个vector
Eigen::Vector3f v11.0f,0.0f,0.0f);
std::cout <<"Vector3f:" << v1 << std::endl;
Eigen::Vector3f v20.0f,1.0f,0.0f);
//点乘
std::cout <<"Vector3f dot:" << v1.dotv2) << std::endl;
std::cout <<"Vector3f dot:" << v2.dotv1) << std::endl;
//叉乘
std::cout <<"Vector3f cross:" << v1.crossv2) << std::endl;
std::cout <<"Vector3f cross:" << v2.crossv1) << std::endl;
Eigen::Vector3f v35.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 <<"Matrix3f2,2):"<< m1,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);
}

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注