GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
math_euler.cpp
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
8#include "math_euler.h"
9
10#include <cmath>
11#include <sstream>
12
14#include "math_rot_converter.h"
15
16
17namespace designlab
18{
19
20std::string EulerXYZ::ToString() const
21{
22 std::string str;
23
24 str += "( x-axis: "
25 + math_util::FloatingPointNumToString(x_angle) + " [rad], y-axis : "
26 + math_util::FloatingPointNumToString(y_angle) + " [rad], z-axis: "
27 + math_util::FloatingPointNumToString(z_angle) + " [rad]) xyz-euler angles";
28
29 return str;
30}
31
32std::string EulerXYZ::ToCsvString() const
33{
34 std::stringstream ss;
35 ss << *this;
36 return ss.str();
37}
38
39std::string EulerXYZ::ToStringDeg() const
40{
43
44 std::string str;
45
46 str += "( x-axis: " + FloatingPointNumToString(ConvertRadToDeg(x_angle)) + " [deg], y-axis : " +
47 FloatingPointNumToString(ConvertRadToDeg(y_angle)) +
48 " [deg], z-axis: " + FloatingPointNumToString(ConvertRadToDeg(z_angle)) +
49 " [deg]) xyz-euler angles";
50
51 return str;
52}
53
54Vector3 RotateVector3(const Vector3& vec, const EulerXYZ& rot)
55{
56 const RotationMatrix3x3 rot_mat = ToRotationMatrix(rot);
57
58 return RotateVector3(vec, rot_mat);
59}
60
61} // namespace designlab
std::string FloatingPointNumToString(const T num, const int digit=kDigit, const int width=kWidth)
小数を文字列に変換する関数. C++ では C のフォーマットのように %3.3f とかで小数を文字列に変換できないため自作する.
Definition math_util.h:161
constexpr T ConvertRadToDeg(const T rad) noexcept
角度を [rad]から [deg] に変換する関数.
Definition math_util.h:117
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
RotationMatrix3x3 ToRotationMatrix(const Quaternion &q)
クォータニオンから回転角行列への変換.
XYZオイラー角を用いた回転を表す構造体.
Definition math_euler.h:33
float x_angle
X 軸周りの回転 [rad]
Definition math_euler.h:109
float y_angle
Y 軸周りの回転 [rad]
Definition math_euler.h:110
std::string ToStringDeg() const
オイラー角を文字列に変換する. 単位は 度 [deg].
std::string ToCsvString() const
オイラー角をCsv形式の文字列に変換する.カンマ区切り. 単位は ラジアン [rad]
std::string ToString() const
オイラー角を文字列に変換する. 単位は ラジアン [rad]
float z_angle
Z 軸周りの回転 [rad]
Definition math_euler.h:111
3次元の回転行列を表す構造体.
3次元の位置ベクトルを表す構造体.