2016-05-25 10 views
1

私はインターネットを検索してEigenチュートリアルを読んでおり、すべての変形、回転については読んでいますが、2ベクトルに回転を適用する方法はわかりません。通常、行列 - ベクトル積です。使用する必要が乗算演算子混同されるみたいです2ベクトルに適用された固有回転2D

Vector2f rotatedVect = t*v.transpose(); 

: 私は、Visual Studio 2010のWindows 7を使用していますと、ここに私のコードの問題は、このラインである

#define _USE_MATH_DEFINES 
#include <iostream> 
#include <cmath> 
#include <Eigen/Dense> 
#include <Eigen/Geometry> 

using namespace std; 
using Eigen::VectorXd; 
using Eigen::VectorXf; 
using Eigen::Vector2d; 
using Eigen::Vector2f; 
using Eigen::Rotation2Df; 

int main(){ 
    Vector2f v; 
    v << 100.0f,200.0f; 
    cout << "\nthe initial vector is v = \n" << endl << v << endl << endl; 
    float theta = M_PI/4; 
    //Eigen::AffineCompact2d t; 
    Rotation2Df t(theta); 
    t.toRotationMatrix(); 
    printf ("\nUsing an Affine2f\n"); 
    cout <<"\nthe rotation Matrix is \n"<< t.matrix() << std::endl; 
    Vector2f rotatedVect = t*v.transpose(); 
    cout <<"the rotated vector is \n"<< rotatedVect << std::endl; 

    std::cin.get(); 
} 

です。連結または行列 - ベクトル乗算の場合。私はこのライブラリが気に入っていますが、この時点で私はプロジェクトでそれを真剣に考え直しています。これは、Visual Studio 2010でコードを実行すると生成されるエラーです。私はどんな助けもありがとう!

1>------ Rebuild All started: Project: GettingStarted, Configuration: Debug x64 ------ 
1>Build started 5/25/2016 12:52:03 PM. 
1>_PrepareForClean: 
1> Deleting file "x64\Debug\GettingStarted.lastbuildstate". 
1>InitializeBuildStatus: 
1> Creating "x64\Debug\GettingStarted.unsuccessfulbuild" because "AlwaysCreate" was specified. 
1>ClCompile: 
1> firstprog.cpp 
1>firstprog.cpp(18): warning C4305: 'initializing' : truncation from 'double' to 'float' 
1>firstprog.cpp(24): error C2666: 'Eigen::Rotation2D<_Scalar>::operator *' : 2 overloads have similar conversions 
1>   with 
1>   [ 
1>    _Scalar=float 
1>   ] 
1>   c:\users\maider\eigen\src/Geometry/Rotation2D.h(85): could be 'Eigen::Matrix<_Scalar,_Rows,_Cols> Eigen::Rotation2D<_Scalar>::operator *(const Eigen::Matrix<_Scalar,_Rows,_Cols> &) const' 
1>   with 
1>   [ 
1>    _Scalar=float, 
1>    _Rows=2, 
1>    _Cols=1 
1>   ] 
1>   c:\users\maider\eigen\src/Geometry/RotationBase.h(71): or  'Eigen::Matrix<_Scalar,_Rows,_Cols> Eigen::RotationBase<Derived,_Dim>::operator *<Eigen::Transpose<MatrixType>>(const Eigen::EigenBase<Eigen::Transpose<MatrixType>> &) const' 
1>   with 
1>   [ 
1>    _Scalar=float, 
1>    _Rows=2, 
1>    _Cols=1, 
1>    Derived=Eigen::Rotation2D<float>, 
1>    _Dim=2, 
1>    MatrixType=Eigen::Matrix<float,2,1> 
1>   ] 
1>   while trying to match the argument list '(Eigen::Rotation2Df, Eigen::Transpose<MatrixType>)' 
1>   with 
1>   [ 
1>    MatrixType=Eigen::Matrix<float,2,1> 
1>   ] 
1> 
1>Build FAILED. 
1> 
1>Time Elapsed 00:00:01.02 
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== 

答えて

0

最初にEigenのバージョンを確認してください。バージョン3.2.3以下の場合、演算子*のオーバーロードに問題があるようです。 https://forum.kde.org/viewtopic.php?f=74&t=124235&p=326983&hilit=Rotation2D#p326983 を参照してくださいしかし、私は、最新バージョンと、ダウンロードした後、それが働いた

Vector2f rotatedVect = t.toRotationMatrix()*v; 

使用して私のコードを再実行してください!

+2

Vector2f rotateVect = t * v;また働いた – CaribeGirl