Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -8,167 +8,181 @@
|
|||
// ==================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BgcMatrix3x3FP32 distortion;
|
||||
BgcVector3FP32 shift;
|
||||
} BgcAffine3FP32;
|
||||
BGC_FP32_Matrix3x3 distortion;
|
||||
BGC_FP32_Vector3 shift;
|
||||
} BGC_FP32_Affine3;
|
||||
|
||||
typedef struct {
|
||||
BgcMatrix3x3FP64 distortion;
|
||||
BgcVector3FP64 shift;
|
||||
} BgcAffine3FP64;
|
||||
BGC_FP64_Matrix3x3 distortion;
|
||||
BGC_FP64_Vector3 shift;
|
||||
} BGC_FP64_Affine3;
|
||||
|
||||
// ==================== Reset ==================== //
|
||||
|
||||
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine)
|
||||
inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * affine)
|
||||
{
|
||||
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
|
||||
bgc_vector3_reset_fp32(&affine->shift);
|
||||
bgc_fp32_matrix3x3_make_identity(&affine->distortion);
|
||||
bgc_fp32_vector3_reset(&affine->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine)
|
||||
inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine)
|
||||
{
|
||||
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion);
|
||||
bgc_vector3_reset_fp64(&affine->shift);
|
||||
bgc_fp64_matrix3x3_make_identity(&affine->distortion);
|
||||
bgc_fp64_vector3_reset(&affine->shift);
|
||||
}
|
||||
|
||||
// ==================== Make ===================== //
|
||||
|
||||
inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine)
|
||||
inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine)
|
||||
{
|
||||
bgc_matrix3x3_copy_fp32(distortion, &affine->distortion);
|
||||
bgc_vector3_copy_fp32(shift, &affine->shift);
|
||||
bgc_fp32_matrix3x3_copy(distortion, &affine->distortion);
|
||||
bgc_fp32_vector3_copy(shift, &affine->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine)
|
||||
inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine)
|
||||
{
|
||||
bgc_matrix3x3_copy_fp64(distortion, &affine->distortion);
|
||||
bgc_vector3_copy_fp64(shift, &affine->shift);
|
||||
bgc_fp64_matrix3x3_copy(distortion, &affine->distortion);
|
||||
bgc_fp64_vector3_copy(shift, &affine->shift);
|
||||
}
|
||||
|
||||
// ==================== Copy ===================== //
|
||||
|
||||
inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
|
||||
inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
{
|
||||
bgc_matrix3x3_copy_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_vector3_copy_fp32(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector3_copy(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
|
||||
inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
{
|
||||
bgc_matrix3x3_copy_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_vector3_copy_fp64(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector3_copy(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
// ==================== Swap ===================== //
|
||||
|
||||
inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second)
|
||||
{
|
||||
bgc_fp32_matrix3x3_copy(&first->distortion, &second->distortion);
|
||||
bgc_fp32_vector3_copy(&first->shift, &second->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second)
|
||||
{
|
||||
bgc_fp64_matrix3x3_copy(&first->distortion, &second->distortion);
|
||||
bgc_fp64_vector3_copy(&first->shift, &second->shift);
|
||||
}
|
||||
|
||||
// =================== Convert =================== //
|
||||
|
||||
inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination)
|
||||
inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
{
|
||||
bgc_matrix3x3_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination)
|
||||
inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
{
|
||||
bgc_matrix3x3_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
// =================== Invert ==================== //
|
||||
|
||||
inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine)
|
||||
inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
|
||||
{
|
||||
if (!bgc_matrix3x3_invert_fp32(&affine->distortion, &affine->distortion)) {
|
||||
if (!bgc_fp32_matrix3x3_invert(&affine->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_vector3_make_opposite_fp32(&affine->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp32_vector3_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine)
|
||||
inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
|
||||
{
|
||||
if (!bgc_matrix3x3_invert_fp64(&affine->distortion, &affine->distortion)) {
|
||||
if (!bgc_fp64_matrix3x3_invert(&affine->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_vector3_make_opposite_fp64(&affine->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp64_vector3_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ================= Get Inverse ================= //
|
||||
|
||||
inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
|
||||
inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
{
|
||||
if (!bgc_matrix3x3_invert_fp32(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp32_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix3x3_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_vector3_make_opposite_fp32(&destination->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp32_vector3_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
|
||||
inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
{
|
||||
if (!bgc_matrix3x3_invert_fp64(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp64_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix3x3_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_vector3_make_opposite_fp64(&destination->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp64_vector3_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// =================== Combine =================== //
|
||||
|
||||
inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * first, const BgcAffine3FP32 * second, BgcAffine3FP32 * combination)
|
||||
inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination)
|
||||
{
|
||||
BgcVector3FP32 first_shift;
|
||||
bgc_matrix3x3_get_right_product_fp32(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_matrix_product_3x3_at_3x3_fp32(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_vector3_add_fp32(&first_shift, &second->shift, &combination->shift);
|
||||
BGC_FP32_Vector3 first_shift;
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_fp32_vector3_add(&first_shift, &second->shift, &combination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination)
|
||||
inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination)
|
||||
{
|
||||
BgcVector3FP64 first_shift;
|
||||
bgc_matrix3x3_get_right_product_fp64(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_matrix_product_3x3_at_3x3_fp64(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_vector3_add_fp64(&first_shift, &second->shift, &combination->shift);
|
||||
BGC_FP64_Vector3 first_shift;
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_fp64_vector3_add(&first_shift, &second->shift, &combination->shift);
|
||||
}
|
||||
|
||||
// =============== Transform Point =============== //
|
||||
|
||||
inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point)
|
||||
inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point)
|
||||
{
|
||||
BgcVector3FP32 distorted;
|
||||
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
|
||||
bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point);
|
||||
BGC_FP32_Vector3 distorted;
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted);
|
||||
bgc_fp32_vector3_add(&affine->shift, &distorted, transformed_point);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point)
|
||||
inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_point)
|
||||
{
|
||||
BgcVector3FP64 distorted;
|
||||
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
|
||||
bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point);
|
||||
BGC_FP64_Vector3 distorted;
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted);
|
||||
bgc_fp64_vector3_add(&affine->shift, &distorted, transformed_point);
|
||||
}
|
||||
|
||||
// ============== Transform Vector =============== //
|
||||
|
||||
inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector)
|
||||
inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector)
|
||||
{
|
||||
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
|
||||
}
|
||||
|
||||
inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector)
|
||||
inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_vector)
|
||||
{
|
||||
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue