我是靠谱客的博主 美好小蚂蚁,这篇文章主要介绍已知两个坐标系下的坐标,求坐标系之间的转换矩阵(三),现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream> #include <GTEngine/Mathematics/GteConvertCoordinates.h> using namespace gte; 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; 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, true); // isRHU = convert.IsRightHandedU(); // false // isRHV = convert.IsRightHandedV(); // true X = { 3.0, 7.0, 0.0, 1.0 }; Matrix<4, 4, double> matrix; matrix = convert.GetInverseC(); std::cout<<"transform matrix----------- " <<std::endl; 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[j]<<" "; } std::cout<<std::endl; } std::cout<<"YY matrix * X ------------- " <<std::endl; Vector<4, double> YY; YY = matrix * X; for(int i = 0; i < 4; i++) { std::cout<<"YY "<< i<<": " <<YY[i]<<std::endl; } std::cout<<"Y UToV----------------" <<std::endl; Y = convert.UToV(X); // for(int i = 0; i < 4; i++) { std::cout<<"Y "<< i<<": " <<Y[i]<<std::endl; } // std::cout<<"YY ------------- " <<std::endl; // X = { 1.0, 0.0, 0.0, 1.0 }; // YY = matrix * X; // for(int i = 0; i < 4; i++) // { // std::cout<<"YY "<< i<<": " <<YY[i]<<std::endl; // } } // >> 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

输出:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
itfanr@itfanr-pc:test$ g++ gte_test.cpp -I/usr/local/include/GTEngine -std=c++11 -lgtengine -lX11 -lXext -lGL -lEGL -lpng -lpthread -lm itfanr@itfanr-pc:test$ ./a.out transform matrix----------- 0.866 -0.5 0 10 0.5 0.866 0 5 0 0 1 0 0 0 0 1 YY matrix * X ------------- YY 0: 9.098 YY 1: 12.562 YY 2: 0 YY 3: 1 Y UToV---------------- Y 0: 9.098 Y 1: 12.562 Y 2: 0 Y 3: 1

最后

以上就是美好小蚂蚁最近收集整理的关于已知两个坐标系下的坐标,求坐标系之间的转换矩阵(三)的全部内容,更多相关已知两个坐标系下内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部