本例子只有旋转,没有平移
#include
#include
using namespace gte;
// #define Vector4 Vector<4, double>
int main(int argc, char const *argv[])
{
// // Affine change of basis.
ConvertCoordinates<4, double> convert;
Vector<4, double> X, Y, P0, P1, diff;
Matrix<4, 4, double> U, V, A, B;
bool isRHU, isRHV;
// U.SetCol(0, Vector<4, double>{1.0, 0.0, 0.0, 0.0});
// U.SetCol(1, Vector<4, double>{0.0, 1.0, 0.0, 0.0});
// U.SetCol(2, Vector<4, double>{0.0, 0.0, 1.0, 0.0});
// U.SetCol(3, Vector<4, double>{0.0, 0.0, 0.0, 1.0});
// V.SetCol(0, Vector<4, double>{0.866, 0.5, 0.0, 0.0});
// V.SetCol(1, Vector<4, double>{-0.5, 0.866, 0.0, 0.0});
// V.SetCol(2, Vector<4, double>{0.0, 0.0, 1.0, 0.0});
// V.SetCol(3, Vector<4, double>{0.0, 0.0, 0.0, 1.0});
V.SetCol(0, Vector<4, double>{1.0, 0.0, 0.0, 0.0});
V.SetCol(1, Vector<4, double>{0.0, 1.0, 0.0, 0.0});
V.SetCol(2, Vector<4, double>{0.0, 0.0, 1.0, 0.0});
V.SetCol(3, Vector<4, double>{0.0, 0.0, 0.0, 1.0});
U.SetCol(0, Vector<4, double>{0.866, 0.5, 0.0, 0.0});
U.SetCol(1, Vector<4, double>{-0.5, 0.866, 0.0, 0.0});
U.SetCol(2, Vector<4, double>{0.0, 0.0, 1.0, 0.0});
U.SetCol(3, Vector<4, double>{0.0, 0.0, 0.0, 1.0});
convert(U, true, V, false);
// Matrix<4, 4, double> matrix;
// matrix = convert.GetC();
// for(int i = 0; i <4 ; i++)
// {
// Vector<4,double > row = matrix.GetRow(i);
// for(size_t j = 0; j < 4; j++)
// {
// std::cout<< row[i]<<" ";
// }
// std::cout<
编译:
g++ gte_test.cpp -I/usr/local/include/GTEngine -std=c++11 -L/home/itfanr/GeometricTools/GTEngine/lib/Release -lgtengine
输出:
itfanr@itfanr-pc:test$ ./a.out
Y 0: -1
Y 1: 1.732
Y 2: 0
Y 3: 1