Переход на парадигму Destination first в порядке параметров функий
This commit is contained in:
parent
f7e41645fe
commit
03627f4401
41 changed files with 1570 additions and 1978 deletions
|
|
@ -2,7 +2,7 @@
|
|||
#define _BGC_AFFINE3_H_INCLUDED_
|
||||
|
||||
#include "vector3.h"
|
||||
#include "matrixes.h"
|
||||
#include "matrices.h"
|
||||
#include "matrix3x3.h"
|
||||
|
||||
// ==================== Types ==================== //
|
||||
|
|
@ -33,58 +33,58 @@ inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine)
|
|||
|
||||
// ==================== Make ===================== //
|
||||
|
||||
inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine)
|
||||
inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift)
|
||||
{
|
||||
bgc_fp32_matrix3x3_copy(distortion, &affine->distortion);
|
||||
bgc_fp32_vector3_copy(shift, &affine->shift);
|
||||
bgc_fp32_matrix3x3_copy(&affine->distortion, distortion);
|
||||
bgc_fp32_vector3_copy(&affine->shift, shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine)
|
||||
inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift)
|
||||
{
|
||||
bgc_fp64_matrix3x3_copy(distortion, &affine->distortion);
|
||||
bgc_fp64_vector3_copy(shift, &affine->shift);
|
||||
bgc_fp64_matrix3x3_copy(&affine->distortion, distortion);
|
||||
bgc_fp64_vector3_copy(&affine->shift, shift);
|
||||
}
|
||||
|
||||
// ==================== Copy ===================== //
|
||||
|
||||
inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
|
||||
{
|
||||
bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector3_copy(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix3x3_copy(&destination->distortion, &source->distortion);
|
||||
bgc_fp32_vector3_copy(&destination->shift, &source->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
|
||||
{
|
||||
bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector3_copy(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix3x3_copy(&destination->distortion, &source->distortion);
|
||||
bgc_fp64_vector3_copy(&destination->shift, &source->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);
|
||||
bgc_fp32_matrix3x3_swap(&first->distortion, &second->distortion);
|
||||
bgc_fp32_vector3_swap(&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);
|
||||
bgc_fp64_matrix3x3_swap(&first->distortion, &second->distortion);
|
||||
bgc_fp64_vector3_swap(&first->shift, &second->shift);
|
||||
}
|
||||
|
||||
// =================== Convert =================== //
|
||||
|
||||
inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3 * source)
|
||||
{
|
||||
bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix3x3_convert_to_fp64(&destination->distortion, &source->distortion);
|
||||
bgc_fp32_vector3_convert_to_fp64(&destination->shift, &source->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source)
|
||||
{
|
||||
bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix3x3_convert_to_fp32(&destination->distortion, &source->distortion);
|
||||
bgc_fp64_vector3_convert_to_fp32(&destination->shift, &source->shift);
|
||||
}
|
||||
|
||||
// =================== Invert ==================== //
|
||||
|
|
@ -95,7 +95,7 @@ inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp32_vector3_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
|
|
@ -107,7 +107,7 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
|
||||
bgc_fp64_vector3_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
|
|
@ -115,25 +115,25 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
|
|||
|
||||
// ================= Get Inverse ================= //
|
||||
|
||||
inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
|
||||
inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
|
||||
{
|
||||
if (!bgc_fp32_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp32_vector3_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
|
||||
inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
|
||||
{
|
||||
if (!bgc_fp64_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
|
||||
bgc_fp64_vector3_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
|
|
@ -141,48 +141,48 @@ inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP6
|
|||
|
||||
// =================== Combine =================== //
|
||||
|
||||
inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination)
|
||||
inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second)
|
||||
{
|
||||
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);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp32_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp32_vector3_add(&combination->shift, &first_shift, &second->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination)
|
||||
inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second)
|
||||
{
|
||||
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);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift);
|
||||
bgc_fp64_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion);
|
||||
bgc_fp64_vector3_add(&combination->shift, &first_shift, &second->shift);
|
||||
}
|
||||
|
||||
// =============== Transform Point =============== //
|
||||
|
||||
inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point)
|
||||
inline void bgc_fp32_affine3_transform_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_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);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp32_vector3_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_point)
|
||||
inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_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);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point);
|
||||
bgc_fp64_vector3_add(transformed_point, &affine->shift, &distorted);
|
||||
}
|
||||
|
||||
// ============== Transform Vector =============== //
|
||||
|
||||
inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector)
|
||||
inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector)
|
||||
{
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp32_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_vector)
|
||||
inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector)
|
||||
{
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp64_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue