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
13#include "math_rot_converter.h"
15
16namespace designlab {
17
18std::string EulerXYZ::ToString() const {
19 std::string str;
20
21 str += "( x-axis: " + math_util::FloatingPointNumToString(x_angle) +
22 " [rad], y-axis : " + math_util::FloatingPointNumToString(y_angle) +
23 " [rad], z-axis: " + math_util::FloatingPointNumToString(z_angle) +
24 " [rad]) xyz-euler angles";
25
26 return str;
27}
28
29std::string EulerXYZ::ToCsvString() const {
30 std::stringstream ss;
31 ss << *this;
32 return ss.str();
33}
34
35std::string EulerXYZ::ToStringDeg() const {
38
39 std::string str;
40
41 str +=
42 "( x-axis: " + FloatingPointNumToString(ConvertRadToDeg(x_angle)) +
43 " [deg], y-axis : " + FloatingPointNumToString(ConvertRadToDeg(y_angle)) +
44 " [deg], z-axis: " + FloatingPointNumToString(ConvertRadToDeg(z_angle)) +
45 " [deg]) xyz-euler angles";
46
47 return str;
48}
49
50Vector3 RotateVector3(const Vector3& vec, const EulerXYZ& rot) {
51 const RotationMatrix3x3 rot_mat = ToRotationMatrix(rot);
52
53 return RotateVector3(vec, rot_mat);
54}
55
56} // namespace designlab
std::string FloatingPointNumToString(const T num, const int digit=kDigit, const int width=kWidth)
小数を文字列に変換する関数. C++ では C のフォーマットのように %3.3f とかで小数を文字列に変換できないため自作する.
Definition math_util.h:152
constexpr T ConvertRadToDeg(const T rad) noexcept
角度を [rad]から [deg] に変換する関数.
Definition math_util.h:110
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
RotationMatrix3x3 ToRotationMatrix(const Quaternion &q)
クォータニオンから回転角行列への変換.
XYZオイラー角を用いた回転を表す構造体.
Definition math_euler.h:30
float x_angle
X 軸周りの回転 [rad]
Definition math_euler.h:99
float y_angle
Y 軸周りの回転 [rad]
Definition math_euler.h:100
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:101
3次元の回転行列を表す構造体.
3次元の位置ベクトルを表す構造体.