This commit is contained in:
aozhiwei 2022-09-06 10:21:21 +08:00
parent 3e5ad07a23
commit 9b63b8fee2
2 changed files with 35 additions and 1 deletions

View File

@ -5,9 +5,40 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/vec3.hpp>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <a8/vec3.h>
namespace a8
{
void Vec3::RotateX(float angle)
{
Eigen::Vector3f v(x, y, z);
v = Eigen::AngleAxisf(angle * 3.1415926f, Eigen::Vector3f::UnitX()) * v;
x = v[0];
y = v[1];
z = v[2];
}
void Vec3::RotateY(float angle)
{
Eigen::Vector3f v(x, y, z);
v = Eigen::AngleAxisf(angle * 3.1415926f, Eigen::Vector3f::UnitY()) * v;
x = v[0];
y = v[1];
z = v[2];
}
void Vec3::RotateZ(float angle)
{
Eigen::Vector3f v(x, y, z);
v = Eigen::AngleAxisf(angle * 3.1415926f, Eigen::Vector3f::UnitZ()) * v;
x = v[0];
y = v[1];
z = v[2];
}
}

View File

@ -9,7 +9,10 @@ namespace a8
float y = 0.0f;
float z = 0.0f;
Vec3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f):x(_x), y(_y), z(_z) {};
Vec3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f):x(_x), y(_y), z(_z) {};
void RotateX(float angle);
void RotateY(float angle);
void RotateZ(float angle);
};
}