🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
Transform.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstMath/Rotation.hpp"
25
26AST_NAMESPACE_BEGIN
27
28
33{
34public:
35
37 Transform() = default;
38
40 Transform(const Vector3d& trans, const Rotation& rot);
41
45 static Transform Identity();
46
49 const Rotation& getRotation() const { return rotation_; }
50 Rotation& getRotation() { return rotation_; }
51
54 void setRotation(const Rotation& rotation) { rotation_ = rotation; }
55
58 const Vector3d& getTranslation() const { return translation_; }
59 Vector3d& getTranslation() { return translation_; }
60
63 void setTranslation(const Vector3d& translation) { translation_ = translation; }
64
67 const Matrix3d& getMatrix() const { return rotation_.getMatrix(); }
68
72 Transform& compose(const Transform& next);
73
78 Transform composed(const Transform& next) const;
79
84 Transform operator*(const Transform& next) const;
85
90 Transform& operator*=(const Transform& next);
91
94 void getInverse(Transform& inversed) const;
95
98 Transform inverse() const;
99
101 void setIdentity() { rotation_ = Rotation::Identity(); translation_ = Vector3d::Zero(); }
102
106 void transformPosition(const Vector3d& position, Vector3d& positionOut) const;
107
111 Vector3d transformPosition(const Vector3d& position) const;
112
113protected:
114 Vector3d translation_;
116};
117
118A_ALWAYS_INLINE Transform::Transform(const Vector3d &trans, const Rotation &rot)
119 : translation_(trans), rotation_(rot)
120{
121}
122
124{
125 return Transform(Vector3d::Zero(), Rotation::Identity());
126}
127
128A_ALWAYS_INLINE Transform &Transform::compose(const Transform &next)
129{
132 return *this;
133}
134
135A_ALWAYS_INLINE Transform Transform::composed(const Transform &next) const
136{
140 return Transform(
143 );
144}
145
146A_ALWAYS_INLINE Transform Transform::operator*(const Transform &next) const
147{
148 return this->composed(next);
149}
150
151A_ALWAYS_INLINE Transform &Transform::operator*=(const Transform &next)
152{
153 return this->compose(next);
154}
155
156A_ALWAYS_INLINE void Transform::getInverse(Transform &inversed) const
157{
159 rotation_.getInverse(inversed.getRotation());
160}
161
162A_ALWAYS_INLINE Transform Transform::inverse() const
163{
164 Transform retval;
165 this->getInverse(retval);
166 return retval;
167}
168
169A_ALWAYS_INLINE void Transform::transformPosition(const Vector3d &position, Vector3d &positionOut) const
170{
174 rotation_.transformVector(position - translation_, positionOut);
175}
176
177A_ALWAYS_INLINE Vector3d Transform::transformPosition(const Vector3d &position) const
178{
179 Vector3d retval;
180 this->transformPosition(position, retval);
181 return retval;
182}
183
184AST_NAMESPACE_END
坐标系旋转类
定义 Rotation.hpp:39
void transformVector(const Vector3d &vector, Vector3d &vectorOut) const
变换向量
定义 Rotation.hpp:302
void getInverse(Rotation &inversed) const
获取逆旋转
定义 Rotation.hpp:290
static Rotation Identity()
单位旋转
定义 Rotation.hpp:217
Rotation composed(const Rotation &next) const
组合下一个旋转
定义 Rotation.hpp:275
坐标系转换类
定义 Transform.hpp:33
void setTranslation(const Vector3d &translation)
设置坐标系平移
定义 Transform.hpp:63
Transform operator*(const Transform &next) const
组合下一个坐标系转换
定义 Transform.hpp:146
Transform & compose(const Transform &next)
组合下一个坐标系转换
定义 Transform.hpp:128
const Matrix3d & getMatrix() const
获取转换矩阵
定义 Transform.hpp:67
void transformPosition(const Vector3d &position, Vector3d &positionOut) const
转换位置
定义 Transform.hpp:169
Rotation rotation_
旋转
定义 Transform.hpp:115
const Rotation & getRotation() const
获取坐标系旋转
定义 Transform.hpp:49
Transform composed(const Transform &next) const
组合下一个坐标系转换
定义 Transform.hpp:135
void setIdentity()
设置为单位转换
定义 Transform.hpp:101
Vector3d translation_
平移
定义 Transform.hpp:114
void getInverse(Transform &inversed) const
获取逆转换
定义 Transform.hpp:156
static Transform Identity()
获取单位转换
定义 Transform.hpp:123
Transform()=default
转换默认构造函数
Transform inverse() const
获取逆转换
定义 Transform.hpp:162
void setRotation(const Rotation &rotation)
设置坐标系旋转
定义 Transform.hpp:54
Transform & operator*=(const Transform &next)
组合下一个坐标系转换
定义 Transform.hpp:151
const Vector3d & getTranslation() const
获取坐标系平移
定义 Transform.hpp:58