Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -8,168 +8,182 @@
|
|||
// ==================== Types ==================== //
|
||||
|
||||
typedef struct {
|
||||
BgcMatrix2x2FP32 distortion;
|
||||
BgcVector2FP32 shift;
|
||||
} BgcAffine2FP32;
|
||||
BGC_FP32_Matrix2x2 distortion;
|
||||
BGC_FP32_Vector2 shift;
|
||||
} BGC_FP32_Affine2;
|
||||
|
||||
typedef struct {
|
||||
BgcMatrix2x2FP64 distortion;
|
||||
BgcVector2FP64 shift;
|
||||
} BgcAffine2FP64;
|
||||
BGC_FP64_Matrix2x2 distortion;
|
||||
BGC_FP64_Vector2 shift;
|
||||
} BGC_FP64_Affine2;
|
||||
|
||||
// ==================== Reset ==================== //
|
||||
|
||||
inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine)
|
||||
inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine)
|
||||
{
|
||||
bgc_matrix2x2_set_to_identity_fp32(&affine->distortion);
|
||||
bgc_vector2_reset_fp32(&affine->shift);
|
||||
bgc_fp32_matrix2x2_make_identity(&affine->distortion);
|
||||
bgc_fp32_vector2_reset(&affine->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine)
|
||||
inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine)
|
||||
{
|
||||
bgc_matrix2x2_set_to_identity_fp64(&affine->distortion);
|
||||
bgc_vector2_reset_fp64(&affine->shift);
|
||||
bgc_fp64_matrix2x2_make_identity(&affine->distortion);
|
||||
bgc_fp64_vector2_reset(&affine->shift);
|
||||
}
|
||||
|
||||
// ==================== Make ===================== //
|
||||
|
||||
inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine)
|
||||
inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * affine)
|
||||
{
|
||||
bgc_matrix2x2_copy_fp32(distortion, &affine->distortion);
|
||||
bgc_vector2_copy_fp32(shift, &affine->shift);
|
||||
bgc_fp32_matrix2x2_copy(distortion, &affine->distortion);
|
||||
bgc_fp32_vector2_copy(shift, &affine->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine)
|
||||
inline void bgc_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine)
|
||||
{
|
||||
bgc_matrix2x2_copy_fp64(distortion, &affine->distortion);
|
||||
bgc_vector2_copy_fp64(shift, &affine->shift);
|
||||
bgc_fp64_matrix2x2_copy(distortion, &affine->distortion);
|
||||
bgc_fp64_vector2_copy(shift, &affine->shift);
|
||||
}
|
||||
|
||||
|
||||
// ==================== Copy ===================== //
|
||||
|
||||
inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
|
||||
inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination)
|
||||
{
|
||||
bgc_matrix2x2_copy_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_vector2_copy_fp32(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix2x2_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector2_copy(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
|
||||
inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination)
|
||||
{
|
||||
bgc_matrix2x2_copy_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_vector2_copy_fp64(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix2x2_copy(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector2_copy(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
// ==================== Swap ===================== //
|
||||
|
||||
inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second)
|
||||
{
|
||||
bgc_fp32_matrix2x2_swap(&first->distortion, &second->distortion);
|
||||
bgc_fp32_vector2_swap(&first->shift, &second->shift);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * second)
|
||||
{
|
||||
bgc_fp64_matrix2x2_swap(&first->distortion, &second->distortion);
|
||||
bgc_fp64_vector2_swap(&first->shift, &second->shift);
|
||||
}
|
||||
|
||||
// =================== Convert =================== //
|
||||
|
||||
inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination)
|
||||
inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination)
|
||||
{
|
||||
bgc_matrix2x2_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||
bgc_fp64_matrix2x2_convert_to_fp32(&source->distortion, &destination->distortion);
|
||||
bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination)
|
||||
inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination)
|
||||
{
|
||||
bgc_matrix2x2_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||
bgc_fp32_matrix2x2_convert_to_fp64(&source->distortion, &destination->distortion);
|
||||
bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift);
|
||||
}
|
||||
|
||||
// =================== Invert ==================== //
|
||||
|
||||
inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine)
|
||||
inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
|
||||
{
|
||||
if (!bgc_matrix2x2_invert_fp32(&affine->distortion, &affine->distortion)) {
|
||||
if (!bgc_fp32_matrix2x2_invert(&affine->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_vector2_make_opposite_fp32(&affine->shift);
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp32_vector2_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine)
|
||||
inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
|
||||
{
|
||||
if (!bgc_matrix2x2_invert_fp64(&affine->distortion, &affine->distortion)) {
|
||||
if (!bgc_fp64_matrix2x2_invert(&affine->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_vector2_make_opposite_fp64(&affine->shift);
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift);
|
||||
bgc_fp64_vector2_revert(&affine->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ================= Get Inverse ================= //
|
||||
|
||||
inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
|
||||
inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination)
|
||||
{
|
||||
if (!bgc_matrix2x2_invert_fp32(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp32_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix2x2_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_vector2_make_opposite_fp32(&destination->shift);
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp32_vector2_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
|
||||
inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination)
|
||||
{
|
||||
if (!bgc_matrix2x2_invert_fp64(&source->distortion, &destination->distortion)) {
|
||||
if (!bgc_fp64_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_matrix2x2_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_vector2_make_opposite_fp64(&destination->shift);
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift);
|
||||
bgc_fp64_vector2_revert(&destination->shift);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// =================== Combine =================== //
|
||||
|
||||
inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * first, const BgcAffine2FP32 * second, BgcAffine2FP32 * combination)
|
||||
inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination)
|
||||
{
|
||||
BgcVector2FP32 first_shift;
|
||||
bgc_matrix2x2_get_right_product_fp32(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_matrix_product_2x2_at_2x2_fp32(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_vector2_add_fp32(&first_shift, &second->shift, &combination->shift);
|
||||
BGC_FP32_Vector2 first_shift;
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_fp32_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_fp32_vector2_add(&first_shift, &second->shift, &combination->shift);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination)
|
||||
inline void bgc_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination)
|
||||
{
|
||||
BgcVector2FP64 first_shift;
|
||||
bgc_matrix2x2_get_right_product_fp64(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_matrix_product_2x2_at_2x2_fp64(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_vector2_add_fp64(&first_shift, &second->shift, &combination->shift);
|
||||
BGC_FP64_Vector2 first_shift;
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift);
|
||||
bgc_fp64_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion);
|
||||
bgc_fp64_vector2_add(&first_shift, &second->shift, &combination->shift);
|
||||
}
|
||||
|
||||
// =============== Transform Point =============== //
|
||||
|
||||
inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point)
|
||||
inline void bgc_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * transformed_point)
|
||||
{
|
||||
BgcVector2FP32 distorted;
|
||||
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
|
||||
bgc_vector2_add_fp32(&affine->shift, &distorted, transformed_point);
|
||||
BGC_FP32_Vector2 distorted;
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted);
|
||||
bgc_fp32_vector2_add(&affine->shift, &distorted, transformed_point);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point)
|
||||
inline void bgc_fp64_affine2_transform_point(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * transformed_point)
|
||||
{
|
||||
BgcVector2FP64 distorted;
|
||||
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
|
||||
bgc_vector2_add_fp64(&affine->shift, &distorted, transformed_point);
|
||||
BGC_FP64_Vector2 distorted;
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted);
|
||||
bgc_fp64_vector2_add(&affine->shift, &distorted, transformed_point);
|
||||
}
|
||||
|
||||
// ============== Transform Vector =============== //
|
||||
|
||||
inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector)
|
||||
inline void bgc_fp32_affine2_transform_vector(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * transformed_vector)
|
||||
{
|
||||
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector);
|
||||
}
|
||||
|
||||
inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector)
|
||||
inline void bgc_fp64_affine2_transform_vector(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * transformed_vector)
|
||||
{
|
||||
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
|
||||
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue