zoukankan      html  css  js  c++  java
  • Ubuntu 14.04/16.04/18.04安装最新版Eigen3.3.5

    安装依赖

    sudo apt-get install libopenblas-dev
    
    sudo apt-get install --no-install-recommends libboost1.58-all-dev
    
    sudo apt-get install libx11-dev
    
    sudo apt-get install libgl1-mesa-dev 
    
    sudo apt-get install libglu1-mesa-dev 
    
    sudo apt-get install freeglut3-dev
    
    sudo apt-get install doxygen
    
    sudo apt-get install cmake
    
    sudo wget https://nchc.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.tgz --no-check-certificate
    
    sudo tar -xzvf glew-2.1.0.tgz
    
    cd glew-2.1.0/
    
    sudo make 
    
    sudo make install
    
    sudo ldconfig -v
    

      

    安装Eigen3.3.5

    sudo wget https://github.com/eigenteam/eigen-git-mirror/archive/3.3.5.tar.gz
    
    sudo tar -xzvf 3.3.5.tar.gz 
    
    sudo mv eigen-git-mirror-3.3.5/ eigen-3.3.5/
    
    cd eigen-3.3.5/
    
    sudo mkdir build
    
    sudo cmake ..
    
    sudo make
    
    sudo make install 
    
    sudo ldconfig -v
    

      

    测试

    #CMakeLists.txt
    
    cmake_minimum_required( VERSION 2.8 )
    project(useEigen)
    
    set( CMAKE_BUILD_TYPE "Release" )
    set( CMAKE_CXX_FLAGS "-O3" )
    set( CMAKE_CXX_FLAGS "-std=c++11")
    
    # 添加Eigen头文件
    include_directories( "/usr/local/include/eigen3" )
    
    
    add_executable(useEigen  main.cpp)
    find_package(Eigen3 REQUIRED)
    target_link_libraries(${PROJECT_NAME}  ${EIGEN3_LIBS})
    

      

    //main.cpp
    
    #include <iostream>
    #include <fstream>
    #include <vector>
    
    #include <Eigen/Core>
    #include <Eigen/Dense>
    #include <Eigen/Geometry>
    #include <Eigen/StdVector>
    
    using namespace std;
    int main()
    {
        //1.rotation vector to  rotation matrix
        Eigen::AngleAxisd rotationVector(M_PI/4,Eigen::Vector3d(0,0,1));
        Eigen::Matrix3d rotationMatrix=Eigen::Matrix3d::Identity();
        rotationMatrix=rotationVector.toRotationMatrix();
        cout<<"rotationMatrix 
    "<<rotationMatrix<<endl;
    
        //2.rotation vector to quaterniond
        Eigen::Quaterniond q=Eigen::Quaterniond( rotationVector );
        cout<<"rotation quaternion 
    "<<q.coeffs()<<endl;
    
        //3.rotaion vector to eulerAngles
        Eigen::Vector3d eulerAngle=rotationVector.matrix().eulerAngles(0,1,2);
        cout<<"eulerAngle roll pitch yaw
    "<<180*eulerAngle/M_PI<<endl;
        return 0;
    }
    

      

    CMakeLists.txtmain.cpp放到同一个目录,执行:

    sudo cmake  .
    sudo make
    ./useEigen

    如果能输出:

    rotationMatrix 
     0.707107 -0.707107         0
     0.707107  0.707107         0
            0         0         1
    rotation quaternion 
           0
           0
    0.382683
     0.92388
    eulerAngle roll pitch yaw
    -0
     0
    45
    

      证明Eigen 3.3.5安装成功并且可以被cmake查找引用到.

  • 相关阅读:
    Sql server
    分布式爬虫
    爬取某电影网站最新电影
    随笔写一个简单的爬虫
    python的os模块
    基于python的文件处理
    mysql习惯及主从复制参数设置
    git常用命令
    git实习笔记
    微信公众平台开发接口PHP SDK完整版
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/13461461.html
Copyright © 2011-2022 走看看