GTEngine计算坐标变换
程序员文章站
2022-04-04 12:14:22
...
#include <iostream>
#include <GTEngine/Mathematics/GteConvertCoordinates.h>
using namespace gte;
// #define Vector4<double> 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, 0.0, 1.0, 0.0});
U.SetCol(2, Vector<4, double>{0.0, -1.0, 0.0, 0.0});
U.SetCol(3, Vector<4, double>{1.0, 2.0, 3.0, 1.0});
V.SetCol(0, Vector<4, double>{0.0, 1.0, 0.0, 0.0});
V.SetCol(1, Vector<4, double>{-1.0, 0.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>{4.0, 5.0, 6.0, 1.0});
convert(U, true, V, false);
// std::cout<<"GetC "<<convert.GetC()<<std::endl;
// std::cout<<"V "<<V<<std::endl;
isRHU = convert.IsRightHandedU(); // false
isRHV = convert.IsRightHandedV(); // true
X = { -1.0, 4.0, -3.0, 1.0 };
Y = convert.UToV(X); // { 0.0, 2.0, 1.0, 1.0 }
for(int i = 0; i < 4; i++)
{
std::cout<<"Y "<<Y[i]<<std::endl;
}
// std::cout<<"Y "<<Y<<std::endl;
P0 = U*X;
P1 = V*Y;
diff = P0 - P1; // { 0, 0, 0, 0 }
return 0;
}
编译:
g++ main.cpp -I/usr/local/include/GTEngine -std=c++11 -L/home/itfanr/GeometricTools/GTEngine/lib/Release -lgtengine
下一篇: 购物网-->>订单模块中的几个实体