已知两个坐标系下的坐标,求坐标系之间的转换矩阵(二)

包含平移和旋转变换:

#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;

    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, 1.0, 0.0});
	U.SetCol(3,  Vector<4, double>{10.0, 5.0, 0.0, 1.0});
	convert(U, true, V, false);
    
	isRHU = convert.IsRightHandedU();  // false
	isRHV = convert.IsRightHandedV();  // true

	X = { 3.0, 7.0, 0.0, 1.0 };

	Y = convert.UToV(X);  //
    
    for(int i = 0; i < 4; i++)
    {
     std::cout<<"Y  "<< i<<": " <<Y[i]<<std::endl;
    }
	return 0;
}

matlab codes:
// >> T
// T =

//     0.86600   -0.50000    0.00000   10.00000
//     0.50000    0.86600    0.00000    5.00000
//     0.00000    0.00000    1.00000    0.00000
//     0.00000    0.00000    0.00000    1.00000

// >> T * [1 0 0 0]'
// ans =

//    0.86600
//    0.50000
//    0.00000
//    0.00000

// >> T * [0 1 0 0]'
// ans =

//   -0.50000
//    0.86600
//    0.00000
//    0.00000

// >> T * [0 0 1 0]'
// ans =

//    0
//    0
//    1
//    0

输出:

Y  0: 9.098
Y  1: 12.562
Y  2: 0
Y  3: 1

658.png


本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

会员中心
搜索
«    2025年4月    »
123456
78910111213
14151617181920
21222324252627
282930
网站分类
标签列表
最新留言
    热门文章 | 热评文章 | 随机文章
文章归档
友情链接
  • 订阅本站的 RSS 2.0 新闻聚合
  • 扫描加本站机器视觉QQ群,验证答案为:halcon勇哥的机器视觉
  • 点击查阅微信群二维码
  • 扫描加勇哥的非标自动化群,验证答案:C#/C++/VB勇哥的非标自动化群
  • 扫描加站长微信:站长微信:abc496103864
  • 扫描加站长QQ:
  • 扫描赞赏本站:
  • 留言板:

Powered By Z-BlogPHP 1.7.2

Copyright Your skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864