101 lines
2.5 KiB
C
101 lines
2.5 KiB
C
#ifndef _BASIC_GEOMETRY_ROTATION3_H_
|
|
#define _BASIC_GEOMETRY_ROTATION3_H_
|
|
|
|
#include "basis.h"
|
|
#include "angle.h"
|
|
#include "vector3.h"
|
|
|
|
typedef struct {
|
|
vector3_fp32_t axis;
|
|
float radians;
|
|
} rotation3_fp32_t;
|
|
|
|
typedef struct {
|
|
vector3_fp64_t axis;
|
|
double radians;
|
|
} rotation3_fp64_t;
|
|
|
|
extern const rotation3_fp32_t FP32_IDLE_ROTATION3;
|
|
|
|
extern const rotation3_fp64_t FP64_IDLE_ROTATION3;
|
|
|
|
// =================== Reset ==================== //
|
|
|
|
inline void fp32_rotation_reset(rotation3_fp32_t* rotation)
|
|
{
|
|
rotation->axis.x1 = 0.0f;
|
|
rotation->axis.x2 = 0.0f;
|
|
rotation->axis.x3 = 0.0f;
|
|
|
|
rotation->radians = 0.0f;
|
|
}
|
|
|
|
inline void fp64_rotation_reset(rotation3_fp64_t* rotation)
|
|
{
|
|
rotation->axis.x1 = 0.0;
|
|
rotation->axis.x2 = 0.0;
|
|
rotation->axis.x3 = 0.0;
|
|
|
|
rotation->radians = 0.0;
|
|
}
|
|
|
|
// ==================== Make ==================== //
|
|
|
|
inline void fp32_rotation_set_values(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, rotation3_fp32_t* rotation)
|
|
{
|
|
rotation->axis.x1 = x1;
|
|
rotation->axis.x2 = x2;
|
|
rotation->axis.x3 = x3;
|
|
|
|
if (vector3_fp32_normalize(&rotation->axis)) {
|
|
rotation->radians = fp32_angle_to_radians(angle, unit);
|
|
}
|
|
else {
|
|
rotation->radians = 0.0f;
|
|
}
|
|
}
|
|
|
|
|
|
inline void fp64_rotation_set_values(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, rotation3_fp64_t* rotation)
|
|
{
|
|
rotation->axis.x1 = x1;
|
|
rotation->axis.x2 = x2;
|
|
rotation->axis.x3 = x3;
|
|
|
|
if (vector3_fp64_normalize(&rotation->axis)) {
|
|
rotation->radians = fp64_angle_to_radians(angle, unit);
|
|
}
|
|
else {
|
|
rotation->radians = 0.0;
|
|
}
|
|
}
|
|
|
|
inline void fp32_rotation_set_with_axis(const vector3_fp32_t* axis, const float angle, const angle_unit_t unit, rotation3_fp32_t* rotation)
|
|
{
|
|
rotation->axis.x1 = axis->x1;
|
|
rotation->axis.x2 = axis->x2;
|
|
rotation->axis.x3 = axis->x3;
|
|
|
|
if (vector3_fp32_normalize(&rotation->axis)) {
|
|
rotation->radians = fp32_angle_to_radians(angle, unit);
|
|
}
|
|
else {
|
|
rotation->radians = 0.0f;
|
|
}
|
|
}
|
|
|
|
inline void fp64_rotation_set_with_axis(const vector3_fp64_t* axis, const double angle, const angle_unit_t unit, rotation3_fp64_t* rotation)
|
|
{
|
|
rotation->axis.x1 = axis->x1;
|
|
rotation->axis.x2 = axis->x2;
|
|
rotation->axis.x3 = axis->x3;
|
|
|
|
if (vector3_fp64_normalize(&rotation->axis)) {
|
|
rotation->radians = fp64_angle_to_radians(angle, unit);
|
|
}
|
|
else {
|
|
rotation->radians = 0.0;
|
|
}
|
|
}
|
|
|
|
#endif
|