#ifndef _BASIC_GEOMETRY_ROTATION3_H_ #define _BASIC_GEOMETRY_ROTATION3_H_ #include "basis.h" #include "angle.h" #include "vector3.h" typedef struct { fp32_vector3_t axis; float radians; } fp32_rotation3_t; typedef struct { fp64_vector3_t axis; double radians; } fp64_rotation3_t; extern const fp32_rotation3_t FP32_IDLE_ROTATION3; extern const fp64_rotation3_t FP64_IDLE_ROTATION3; // =================== Reset ==================== // static inline void fp32_rotation_reset(fp32_rotation3_t* rotation) { rotation->axis.x1 = 0.0f; rotation->axis.x2 = 0.0f; rotation->axis.x3 = 0.0f; rotation->radians = 0.0f; } static inline void fp64_rotation_reset(fp64_rotation3_t* rotation) { rotation->axis.x1 = 0.0; rotation->axis.x2 = 0.0; rotation->axis.x3 = 0.0; rotation->radians = 0.0; } // ==================== Make ==================== // static inline void fp32_rotation_set_values(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, fp32_rotation3_t* rotation) { rotation->axis.x1 = x1; rotation->axis.x2 = x2; rotation->axis.x3 = x3; if (fp32_vector3_normalize(&rotation->axis)) { rotation->radians = fp32_angle_to_radians(angle, unit); } else { rotation->radians = 0.0f; } } static inline void fp64_rotation_set_values(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, fp64_rotation3_t* rotation) { rotation->axis.x1 = x1; rotation->axis.x2 = x2; rotation->axis.x3 = x3; if (fp64_vector3_normalize(&rotation->axis)) { rotation->radians = fp64_angle_to_radians(angle, unit); } else { rotation->radians = 0.0; } } static inline void fp32_rotation_set_with_axis(const fp32_vector3_t* axis, const float angle, const angle_unit_t unit, fp32_rotation3_t* rotation) { rotation->axis.x1 = axis->x1; rotation->axis.x2 = axis->x2; rotation->axis.x3 = axis->x3; if (fp32_vector3_normalize(&rotation->axis)) { rotation->radians = fp32_angle_to_radians(angle, unit); } else { rotation->radians = 0.0f; } } static inline void fp64_rotation_set_with_axis(const fp64_vector3_t* axis, const double angle, const angle_unit_t unit, fp64_rotation3_t* rotation) { rotation->axis.x1 = axis->x1; rotation->axis.x2 = axis->x2; rotation->axis.x3 = axis->x3; if (fp64_vector3_normalize(&rotation->axis)) { rotation->radians = fp64_angle_to_radians(angle, unit); } else { rotation->radians = 0.0; } } #endif