Добавлеие позиционирования и аффинного преобразования для 2-мерного пространства, добавление функций для аффинных преобразований и позиционирования
This commit is contained in:
parent
3c2b89f369
commit
101df9f089
12 changed files with 734 additions and 322 deletions
|
|
@ -42,6 +42,10 @@
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
|
<Unit filename="affine3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="affine3.h" />
|
||||||
<Unit filename="main.c">
|
<Unit filename="main.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
28
basic-geometry/affine2.c
Normal file
28
basic-geometry/affine2.c
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "affine2.h"
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine);
|
||||||
|
extern inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine);
|
||||||
|
extern inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination);
|
||||||
|
extern inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination);
|
||||||
|
extern inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination);
|
||||||
|
|
||||||
|
extern inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine);
|
||||||
|
extern inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine);
|
||||||
|
|
||||||
|
extern inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination);
|
||||||
|
extern inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * parent, const BgcAffine2FP32 * child, BgcAffine2FP32 * combination);
|
||||||
|
extern inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * parent, const BgcAffine2FP64 * child, BgcAffine2FP64 * combination);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point);
|
||||||
|
extern inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point);
|
||||||
|
|
||||||
|
extern inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector);
|
||||||
|
extern inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector);
|
||||||
175
basic-geometry/affine2.h
Normal file
175
basic-geometry/affine2.h
Normal file
|
|
@ -0,0 +1,175 @@
|
||||||
|
#ifndef _BGC_AFFINE2_H_INCLUDED_
|
||||||
|
#define _BGC_AFFINE2_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "vector2.h"
|
||||||
|
#include "matrixes.h"
|
||||||
|
#include "matrix2x2.h"
|
||||||
|
|
||||||
|
// ==================== Types ==================== //
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BgcMatrix2x2FP32 distortion;
|
||||||
|
BgcVector2FP32 shift;
|
||||||
|
} BgcAffine2FP32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BgcMatrix2x2FP64 distortion;
|
||||||
|
BgcVector2FP64 shift;
|
||||||
|
} BgcAffine2FP64;
|
||||||
|
|
||||||
|
// ==================== Reset ==================== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_set_to_identity_fp32(&affine->distortion);
|
||||||
|
bgc_vector2_reset_fp32(&affine->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_set_to_identity_fp64(&affine->distortion);
|
||||||
|
bgc_vector2_reset_fp64(&affine->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Make ===================== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_copy_fp32(distortion, &affine->distortion);
|
||||||
|
bgc_vector2_copy_fp32(shift, &affine->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_copy_fp64(distortion, &affine->distortion);
|
||||||
|
bgc_vector2_copy_fp64(shift, &affine->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== Copy ===================== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_copy_fp32(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector2_copy_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_copy_fp64(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector2_copy_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Convert =================== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Invert ==================== //
|
||||||
|
|
||||||
|
inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix2x2_invert_fp32(&affine->distortion, &affine->distortion)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
|
||||||
|
bgc_vector2_make_opposite_fp32(&affine->shift);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix2x2_invert_fp64(&affine->distortion, &affine->distortion)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
|
||||||
|
bgc_vector2_make_opposite_fp64(&affine->shift);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Get Inverse ================= //
|
||||||
|
|
||||||
|
inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix2x2_invert_fp32(&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);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix2x2_invert_fp64(&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);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Combine =================== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * parent, const BgcAffine2FP32 * child, BgcAffine2FP32 * combination)
|
||||||
|
{
|
||||||
|
BgcVector2FP32 child_shift;
|
||||||
|
bgc_matrix2x2_get_right_product_fp32(&parent->distortion, &child->shift, &child_shift);
|
||||||
|
bgc_matrix_product_2x2_at_2x2_fp32(&parent->distortion, &child->distortion, &combination->distortion);
|
||||||
|
bgc_vector2_add_fp32(&parent->shift, &child_shift, &combination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * parent, const BgcAffine2FP64 * child, BgcAffine2FP64 * combination)
|
||||||
|
{
|
||||||
|
BgcVector2FP64 child_shift;
|
||||||
|
bgc_matrix2x2_get_right_product_fp64(&parent->distortion, &child->shift, &child_shift);
|
||||||
|
bgc_matrix_product_2x2_at_2x2_fp64(&parent->distortion, &child->distortion, &combination->distortion);
|
||||||
|
bgc_vector2_add_fp64(&parent->shift, &child_shift, &combination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =============== Transform Point =============== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP32 distorted;
|
||||||
|
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
|
||||||
|
bgc_vector2_add_fp32(&affine->shift, &distorted, transformed_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP64 distorted;
|
||||||
|
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
|
||||||
|
bgc_vector2_add_fp64(&affine->shift, &distorted, transformed_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============== Transform Vector =============== //
|
||||||
|
|
||||||
|
inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector)
|
||||||
|
{
|
||||||
|
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -3,15 +3,21 @@
|
||||||
extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine);
|
extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine);
|
||||||
extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine);
|
extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine);
|
||||||
|
|
||||||
extern inline void bgc_affine3_reset_distortion_fp32(BgcAffine3FP32 * affine);
|
|
||||||
extern inline void bgc_affine3_reset_distortion_fp64(BgcAffine3FP64 * affine);
|
|
||||||
|
|
||||||
extern inline void bgc_affine3_reset_shift_fp32(BgcAffine3FP32 * affine);
|
|
||||||
extern inline void bgc_affine3_reset_shift_fp64(BgcAffine3FP64 * affine);
|
|
||||||
|
|
||||||
extern inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine);
|
extern inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine);
|
||||||
extern inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine);
|
extern inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine);
|
||||||
|
|
||||||
|
extern inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination);
|
||||||
|
extern inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination);
|
||||||
|
extern inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination);
|
||||||
|
|
||||||
|
extern inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine);
|
||||||
|
extern inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine);
|
||||||
|
|
||||||
|
extern inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination);
|
||||||
|
extern inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination);
|
||||||
|
|
||||||
extern inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * parent, const BgcAffine3FP32 * child, BgcAffine3FP32 * combination);
|
extern inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * parent, const BgcAffine3FP32 * child, BgcAffine3FP32 * combination);
|
||||||
extern inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * parent, const BgcAffine3FP64 * child, BgcAffine3FP64 * combination);
|
extern inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * parent, const BgcAffine3FP64 * child, BgcAffine3FP64 * combination);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef _BGC_AFFINE3_H_INCLUDED_
|
#ifndef _BGC_AFFINE3_H_INCLUDED_
|
||||||
#define _BGC_AFFINE3_H_INCLUDED_
|
#define _BGC_AFFINE3_H_INCLUDED_
|
||||||
|
|
||||||
#include "utilities.h"
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "matrixes.h"
|
#include "matrixes.h"
|
||||||
#include "matrix3x3.h"
|
#include "matrix3x3.h"
|
||||||
|
|
@ -9,333 +8,167 @@
|
||||||
// ==================== Types ==================== //
|
// ==================== Types ==================== //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcMatrix3x3FP32 distortion;
|
BgcMatrix3x3FP32 distortion;
|
||||||
BgcVector3FP32 shift;
|
BgcVector3FP32 shift;
|
||||||
#else
|
|
||||||
float r1c1, r1c2, r1c3, shift1;
|
|
||||||
float r2c1, r2c2, r2c3, shift2;
|
|
||||||
float r3c1, r3c2, r3c3, shift3;
|
|
||||||
#endif
|
|
||||||
} BgcAffine3FP32;
|
} BgcAffine3FP32;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcMatrix3x3FP64 distortion;
|
BgcMatrix3x3FP64 distortion;
|
||||||
BgcVector3FP64 shift;
|
BgcVector3FP64 shift;
|
||||||
#else
|
|
||||||
double r1c1, r1c2, r1c3, shift1;
|
|
||||||
double r2c1, r2c2, r2c3, shift2;
|
|
||||||
double r3c1, r3c2, r3c3, shift3;
|
|
||||||
#endif
|
|
||||||
} BgcAffine3FP64;
|
} BgcAffine3FP64;
|
||||||
|
|
||||||
// ==================== Reset ==================== //
|
// ==================== Reset ==================== //
|
||||||
|
|
||||||
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine)
|
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
|
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
|
||||||
bgc_vector3_reset_fp32(&affine->shift);
|
bgc_vector3_reset_fp32(&affine->shift);
|
||||||
#else
|
|
||||||
affine->r1c1 = 1.0f;
|
|
||||||
affine->r1c2 = 0.0f;
|
|
||||||
affine->r1c3 = 0.0f;
|
|
||||||
affine->shift1 = 0.0f;
|
|
||||||
|
|
||||||
affine->r2c1 = 0.0f;
|
|
||||||
affine->r2c2 = 1.0f;
|
|
||||||
affine->r2c3 = 0.0f;
|
|
||||||
affine->shift2 = 0.0f;
|
|
||||||
|
|
||||||
affine->r3c1 = 0.0f;
|
|
||||||
affine->r3c2 = 0.0f;
|
|
||||||
affine->r3c3 = 1.0f;
|
|
||||||
affine->shift3 = 0.0f;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine)
|
inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion);
|
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion);
|
||||||
bgc_vector3_reset_fp64(&affine->shift);
|
bgc_vector3_reset_fp64(&affine->shift);
|
||||||
#else
|
|
||||||
affine->r1c1 = 1.0;
|
|
||||||
affine->r1c2 = 0.0;
|
|
||||||
affine->r1c3 = 0.0;
|
|
||||||
affine->shift1 = 0.0;
|
|
||||||
|
|
||||||
affine->r2c1 = 0.0;
|
|
||||||
affine->r2c2 = 1.0;
|
|
||||||
affine->r2c3 = 0.0;
|
|
||||||
affine->shift2 = 0.0;
|
|
||||||
|
|
||||||
affine->r3c1 = 0.0;
|
|
||||||
affine->r3c2 = 0.0;
|
|
||||||
affine->r3c3 = 1.0;
|
|
||||||
affine->shift3 = 0.0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_affine3_reset_distortion_fp32(BgcAffine3FP32 * affine)
|
|
||||||
{
|
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
|
|
||||||
#else
|
|
||||||
affine->r1c1 = 1.0f;
|
|
||||||
affine->r1c2 = 0.0f;
|
|
||||||
affine->r1c3 = 0.0f;
|
|
||||||
|
|
||||||
affine->r2c1 = 0.0f;
|
|
||||||
affine->r2c2 = 1.0f;
|
|
||||||
affine->r2c3 = 0.0f;
|
|
||||||
|
|
||||||
affine->r3c1 = 0.0f;
|
|
||||||
affine->r3c2 = 0.0f;
|
|
||||||
affine->r3c3 = 1.0f;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_affine3_reset_distortion_fp64(BgcAffine3FP64 * affine)
|
|
||||||
{
|
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion);
|
|
||||||
#else
|
|
||||||
affine->r1c1 = 1.0;
|
|
||||||
affine->r1c2 = 0.0;
|
|
||||||
affine->r1c3 = 0.0;
|
|
||||||
|
|
||||||
affine->r2c1 = 0.0;
|
|
||||||
affine->r2c2 = 1.0;
|
|
||||||
affine->r2c3 = 0.0;
|
|
||||||
|
|
||||||
affine->r3c1 = 0.0;
|
|
||||||
affine->r3c2 = 0.0;
|
|
||||||
affine->r3c3 = 1.0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_affine3_reset_shift_fp32(BgcAffine3FP32 * affine)
|
|
||||||
{
|
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_vector3_reset_fp32(&affine->shift);
|
|
||||||
#else
|
|
||||||
affine->shift1 = 0.0f;
|
|
||||||
affine->shift2 = 0.0f;
|
|
||||||
affine->shift3 = 0.0f;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_affine3_reset_shift_fp64(BgcAffine3FP64 * affine)
|
|
||||||
{
|
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_vector3_reset_fp64(&affine->shift);
|
|
||||||
#else
|
|
||||||
affine->shift1 = 0.0;
|
|
||||||
affine->shift2 = 0.0;
|
|
||||||
affine->shift3 = 0.0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Make ===================== //
|
// ==================== Make ===================== //
|
||||||
|
|
||||||
inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine)
|
inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_copy_fp32(distortion, &affine->distortion);
|
bgc_matrix3x3_copy_fp32(distortion, &affine->distortion);
|
||||||
bgc_vector3_copy_fp32(shift, &affine->shift);
|
bgc_vector3_copy_fp32(shift, &affine->shift);
|
||||||
#else
|
|
||||||
affine->r1c1 = distortion->r1c1;
|
|
||||||
affine->r1c2 = distortion->r1c2;
|
|
||||||
affine->r1c3 = distortion->r1c3;
|
|
||||||
affine->shift1 = shift->x1;
|
|
||||||
|
|
||||||
affine->r2c1 = distortion->r2c1;
|
|
||||||
affine->r2c2 = distortion->r2c2;
|
|
||||||
affine->r2c3 = distortion->r2c3;
|
|
||||||
affine->shift2 = shift->x2;
|
|
||||||
|
|
||||||
affine->r3c1 = distortion->r3c1;
|
|
||||||
affine->r3c2 = distortion->r3c2;
|
|
||||||
affine->r3c3 = distortion->r3c3;
|
|
||||||
affine->shift3 = shift->x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine)
|
inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_copy_fp64(distortion, &affine->distortion);
|
bgc_matrix3x3_copy_fp64(distortion, &affine->distortion);
|
||||||
bgc_vector3_copy_fp64(shift, &affine->shift);
|
bgc_vector3_copy_fp64(shift, &affine->shift);
|
||||||
#else
|
}
|
||||||
affine->r1c1 = distortion->r1c1;
|
|
||||||
affine->r1c2 = distortion->r1c2;
|
|
||||||
affine->r1c3 = distortion->r1c3;
|
|
||||||
affine->shift1 = shift->x1;
|
|
||||||
|
|
||||||
affine->r2c1 = distortion->r2c1;
|
// ==================== Copy ===================== //
|
||||||
affine->r2c2 = distortion->r2c2;
|
|
||||||
affine->r2c3 = distortion->r2c3;
|
|
||||||
affine->shift2 = shift->x2;
|
|
||||||
|
|
||||||
affine->r3c1 = distortion->r3c1;
|
inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
|
||||||
affine->r3c2 = distortion->r3c2;
|
{
|
||||||
affine->r3c3 = distortion->r3c3;
|
bgc_matrix3x3_copy_fp32(&source->distortion, &destination->distortion);
|
||||||
affine->shift3 = shift->x3;
|
bgc_vector3_copy_fp32(&source->shift, &destination->shift);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix3x3_copy_fp64(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector3_copy_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Convert =================== //
|
||||||
|
|
||||||
|
inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix3x3_convert_fp64_to_fp32(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_matrix3x3_convert_fp32_to_fp64(&source->distortion, &destination->distortion);
|
||||||
|
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Invert ==================== //
|
||||||
|
|
||||||
|
inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix3x3_invert_fp32(&affine->distortion, &affine->distortion)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift);
|
||||||
|
bgc_vector3_make_opposite_fp32(&affine->shift);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix3x3_invert_fp64(&affine->distortion, &affine->distortion)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift);
|
||||||
|
bgc_vector3_make_opposite_fp64(&affine->shift);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Get Inverse ================= //
|
||||||
|
|
||||||
|
inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix3x3_invert_fp32(&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);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination)
|
||||||
|
{
|
||||||
|
if (!bgc_matrix3x3_invert_fp64(&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);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Combine =================== //
|
// =================== Combine =================== //
|
||||||
|
|
||||||
inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * parent, const BgcAffine3FP32 * child, BgcAffine3FP32 * combination)
|
inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * parent, const BgcAffine3FP32 * child, BgcAffine3FP32 * combination)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcVector3FP32 child_shift;
|
BgcVector3FP32 child_shift;
|
||||||
bgc_matrix3x3_get_right_product_fp32(&parent->distortion, &child->shift, &child_shift);
|
bgc_matrix3x3_get_right_product_fp32(&parent->distortion, &child->shift, &child_shift);
|
||||||
bgc_matrix_product_3x3_at_3x3_fp32(&parent->distortion, &child->distortion, &combination->distortion);
|
bgc_matrix_product_3x3_at_3x3_fp32(&parent->distortion, &child->distortion, &combination->distortion);
|
||||||
bgc_vector3_add_fp32(&parent->shift, &child_shift, &combination->shift);
|
bgc_vector3_add_fp32(&parent->shift, &child_shift, &combination->shift);
|
||||||
#else
|
|
||||||
const float r1c1 = parent->r1c1 * child->r1c1 + parent->r1c2 * child->r2c1 + parent->r1c3 * child->r3c1;
|
|
||||||
const float r1c2 = parent->r1c1 * child->r1c2 + parent->r1c2 * child->r2c2 + parent->r1c3 * child->r3c2;
|
|
||||||
const float r1c3 = parent->r1c1 * child->r1c3 + parent->r1c2 * child->r2c3 + parent->r1c3 * child->r3c3;
|
|
||||||
|
|
||||||
const float r2c1 = parent->r2c1 * child->r1c1 + parent->r2c2 * child->r2c1 + parent->r2c3 * child->r3c1;
|
|
||||||
const float r2c2 = parent->r2c1 * child->r1c2 + parent->r2c2 * child->r2c2 + parent->r2c3 * child->r3c2;
|
|
||||||
const float r2c3 = parent->r2c1 * child->r1c3 + parent->r2c2 * child->r2c3 + parent->r2c3 * child->r3c3;
|
|
||||||
|
|
||||||
const float r3c1 = parent->r3c1 * child->r1c1 + parent->r3c2 * child->r2c1 + parent->r3c3 * child->r3c1;
|
|
||||||
const float r3c2 = parent->r3c1 * child->r1c2 + parent->r3c2 * child->r2c2 + parent->r3c3 * child->r3c2;
|
|
||||||
const float r3c3 = parent->r3c1 * child->r1c3 + parent->r3c2 * child->r2c3 + parent->r3c3 * child->r3c3;
|
|
||||||
|
|
||||||
const float shift1 = parent->r1c1 * child->shift1 + parent->r1c2 * child->shift2 + parent->r1c3 * child->shift3;
|
|
||||||
const float shift2 = parent->r2c1 * child->shift1 + parent->r2c2 * child->shift2 + parent->r2c3 * child->shift3;
|
|
||||||
const float shift3 = parent->r3c1 * child->shift1 + parent->r3c2 * child->shift2 + parent->r3c3 * child->shift3;
|
|
||||||
|
|
||||||
combination->r1c1 = r1c1;
|
|
||||||
combination->r1c2 = r1c2;
|
|
||||||
combination->r1c3 = r1c3;
|
|
||||||
combination->shift1 = shift1;
|
|
||||||
|
|
||||||
combination->r2c1 = r2c1;
|
|
||||||
combination->r2c2 = r2c2;
|
|
||||||
combination->r2c3 = r2c3;
|
|
||||||
combination->shift2 = shift2;
|
|
||||||
|
|
||||||
combination->r3c1 = r3c1;
|
|
||||||
combination->r3c2 = r3c2;
|
|
||||||
combination->r3c3 = r3c3;
|
|
||||||
combination->shift3 = shift3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * parent, const BgcAffine3FP64 * child, BgcAffine3FP64 * combination)
|
inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * parent, const BgcAffine3FP64 * child, BgcAffine3FP64 * combination)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcVector3FP64 child_shift;
|
BgcVector3FP64 child_shift;
|
||||||
bgc_matrix3x3_get_right_product_fp64(&parent->distortion, &child->shift, &child_shift);
|
bgc_matrix3x3_get_right_product_fp64(&parent->distortion, &child->shift, &child_shift);
|
||||||
bgc_matrix_product_3x3_at_3x3_fp64(&parent->distortion, &child->distortion, &combination->distortion);
|
bgc_matrix_product_3x3_at_3x3_fp64(&parent->distortion, &child->distortion, &combination->distortion);
|
||||||
bgc_vector3_add_fp64(&parent->shift, &child_shift, &combination->shift);
|
bgc_vector3_add_fp64(&parent->shift, &child_shift, &combination->shift);
|
||||||
#else
|
|
||||||
const double r1c1 = parent->r1c1 * child->r1c1 + parent->r1c2 * child->r2c1 + parent->r1c3 * child->r3c1;
|
|
||||||
const double r1c2 = parent->r1c1 * child->r1c2 + parent->r1c2 * child->r2c2 + parent->r1c3 * child->r3c2;
|
|
||||||
const double r1c3 = parent->r1c1 * child->r1c3 + parent->r1c2 * child->r2c3 + parent->r1c3 * child->r3c3;
|
|
||||||
|
|
||||||
const double r2c1 = parent->r2c1 * child->r1c1 + parent->r2c2 * child->r2c1 + parent->r2c3 * child->r3c1;
|
|
||||||
const double r2c2 = parent->r2c1 * child->r1c2 + parent->r2c2 * child->r2c2 + parent->r2c3 * child->r3c2;
|
|
||||||
const double r2c3 = parent->r2c1 * child->r1c3 + parent->r2c2 * child->r2c3 + parent->r2c3 * child->r3c3;
|
|
||||||
|
|
||||||
const double r3c1 = parent->r3c1 * child->r1c1 + parent->r3c2 * child->r2c1 + parent->r3c3 * child->r3c1;
|
|
||||||
const double r3c2 = parent->r3c1 * child->r1c2 + parent->r3c2 * child->r2c2 + parent->r3c3 * child->r3c2;
|
|
||||||
const double r3c3 = parent->r3c1 * child->r1c3 + parent->r3c2 * child->r2c3 + parent->r3c3 * child->r3c3;
|
|
||||||
|
|
||||||
const double shift1 = parent->r1c1 * child->shift1 + parent->r1c2 * child->shift2 + parent->r1c3 * child->shift3;
|
|
||||||
const double shift2 = parent->r2c1 * child->shift1 + parent->r2c2 * child->shift2 + parent->r2c3 * child->shift3;
|
|
||||||
const double shift3 = parent->r3c1 * child->shift1 + parent->r3c2 * child->shift2 + parent->r3c3 * child->shift3;
|
|
||||||
|
|
||||||
combination->r1c1 = r1c1;
|
|
||||||
combination->r1c2 = r1c2;
|
|
||||||
combination->r1c3 = r1c3;
|
|
||||||
combination->shift1 = shift1;
|
|
||||||
|
|
||||||
combination->r2c1 = r2c1;
|
|
||||||
combination->r2c2 = r2c2;
|
|
||||||
combination->r2c3 = r2c3;
|
|
||||||
combination->shift2 = shift2;
|
|
||||||
|
|
||||||
combination->r3c1 = r3c1;
|
|
||||||
combination->r3c2 = r3c2;
|
|
||||||
combination->r3c3 = r3c3;
|
|
||||||
combination->shift3 = shift3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Transform Point =============== //
|
// =============== Transform Point =============== //
|
||||||
|
|
||||||
inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point)
|
inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcVector3FP32 distorted;
|
BgcVector3FP32 distorted;
|
||||||
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
|
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted);
|
||||||
bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point);
|
bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point);
|
||||||
#else
|
|
||||||
const float x1 = (affine->r1c1 * initial_point->x1 + affine->r1c2 * initial_point->x2) + (affine->r1c3 * initial_point->x3 + affine->shift1);
|
|
||||||
const float x2 = (affine->r2c1 * initial_point->x1 + affine->r2c2 * initial_point->x2) + (affine->r2c3 * initial_point->x3 + affine->shift2);
|
|
||||||
const float x3 = (affine->r3c1 * initial_point->x1 + affine->r3c2 * initial_point->x2) + (affine->r3c3 * initial_point->x3 + affine->shift3);
|
|
||||||
|
|
||||||
transformed_point->x1 = x1;
|
|
||||||
transformed_point->x2 = x2;
|
|
||||||
transformed_point->x3 = x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point)
|
inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
BgcVector3FP64 distorted;
|
BgcVector3FP64 distorted;
|
||||||
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
|
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted);
|
||||||
bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point);
|
bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point);
|
||||||
#else
|
|
||||||
const double x1 = affine->r1c1 * initial_point->x1 + affine->r1c2 * initial_point->x2 + affine->r1c3 * initial_point->x3 + affine->shift1;
|
|
||||||
const double x2 = affine->r2c1 * initial_point->x1 + affine->r2c2 * initial_point->x2 + affine->r2c3 * initial_point->x3 + affine->shift2;
|
|
||||||
const double x3 = affine->r3c1 * initial_point->x1 + affine->r3c2 * initial_point->x2 + affine->r3c3 * initial_point->x3 + affine->shift3;
|
|
||||||
|
|
||||||
transformed_point->x1 = x1;
|
|
||||||
transformed_point->x2 = x2;
|
|
||||||
transformed_point->x3 = x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Transform Vector =============== //
|
// ============== Transform Vector =============== //
|
||||||
|
|
||||||
inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector)
|
inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
|
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector);
|
||||||
#else
|
|
||||||
const float x1 = affine->r1c1 * initial_vector->x1 + affine->r1c2 * initial_vector->x2 + affine->r1c3 * initial_vector->x3;
|
|
||||||
const float x2 = affine->r2c1 * initial_vector->x1 + affine->r2c2 * initial_vector->x2 + affine->r2c3 * initial_vector->x3;
|
|
||||||
const float x3 = affine->r3c1 * initial_vector->x1 + affine->r3c2 * initial_vector->x2 + affine->r3c3 * initial_vector->x3;
|
|
||||||
|
|
||||||
transformed_vector->x1 = x1;
|
|
||||||
transformed_vector->x2 = x2;
|
|
||||||
transformed_vector->x3 = x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector)
|
inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
|
||||||
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
|
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector);
|
||||||
#else
|
|
||||||
const double x1 = affine->r1c1 * initial_vector->x1 + affine->r1c2 * initial_vector->x2 + affine->r1c3 * initial_vector->x3;
|
|
||||||
const double x2 = affine->r2c1 * initial_vector->x1 + affine->r2c2 * initial_vector->x2 + affine->r2c3 * initial_vector->x3;
|
|
||||||
const double x3 = affine->r3c1 * initial_vector->x1 + affine->r3c2 * initial_vector->x2 + affine->r3c3 * initial_vector->x3;
|
|
||||||
|
|
||||||
transformed_vector->x1 = x1;
|
|
||||||
transformed_vector->x2 = x2;
|
|
||||||
transformed_vector->x3 = x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _BGC_AFFINE3_H_INCLUDED_
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,14 @@
|
||||||
</Linker>
|
</Linker>
|
||||||
</Target>
|
</Target>
|
||||||
</Build>
|
</Build>
|
||||||
|
<Unit filename="affine2.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="affine2.h" />
|
||||||
|
<Unit filename="affine3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="affine3.h" />
|
||||||
<Unit filename="angle.c">
|
<Unit filename="angle.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
@ -76,10 +84,14 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="matrixes.h" />
|
<Unit filename="matrixes.h" />
|
||||||
<Unit filename="position.c">
|
<Unit filename="position2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="position.h" />
|
<Unit filename="position2.h" />
|
||||||
|
<Unit filename="position3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="position3.h" />
|
||||||
<Unit filename="quaternion.c">
|
<Unit filename="quaternion.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "./matrix3x2.h"
|
#include "./matrix3x2.h"
|
||||||
#include "./matrix3x3.h"
|
#include "./matrix3x3.h"
|
||||||
|
|
||||||
|
#include "./affine2.h"
|
||||||
#include "./affine3.h"
|
#include "./affine3.h"
|
||||||
|
|
||||||
#include "./complex.h"
|
#include "./complex.h"
|
||||||
|
|
@ -25,6 +26,7 @@
|
||||||
#include "./versor.h"
|
#include "./versor.h"
|
||||||
#include "./slerp.h"
|
#include "./slerp.h"
|
||||||
|
|
||||||
|
#include "./position2.h"
|
||||||
#include "./position3.h"
|
#include "./position3.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
40
basic-geometry/position2.c
Normal file
40
basic-geometry/position2.c
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "position2.h"
|
||||||
|
|
||||||
|
extern inline void bgc_position2_reset_fp32(BgcPosition2FP32 * node);
|
||||||
|
extern inline void bgc_position2_reset_fp64(BgcPosition2FP64 * node);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_make_fp32(const BgcCotesNumberFP32 * turn, const BgcVector2FP32 * shift, BgcPosition2FP32 * position);
|
||||||
|
extern inline void bgc_position2_make_fp64(const BgcCotesNumberFP64 * turn, const BgcVector2FP64 * shift, BgcPosition2FP64 * position);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_copy_fp32(const BgcPosition2FP32 * source, BgcPosition2FP32 * destination);
|
||||||
|
extern inline void bgc_position2_copy_fp64(const BgcPosition2FP64 * source, BgcPosition2FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_convert_fp64_to_fp32(const BgcPosition2FP64 * source, BgcPosition2FP32 * destination);
|
||||||
|
extern inline void bgc_position2_convert_fp32_to_fp64(const BgcPosition2FP32 * source, BgcPosition2FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_invert_fp32(BgcPosition2FP32 * position);
|
||||||
|
extern inline void bgc_position2_invert_fp64(BgcPosition2FP64 * position);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_get_inverse_fp32(const BgcPosition2FP32 * position, BgcPosition2FP32 * inverted);
|
||||||
|
extern inline void bgc_position2_get_inverse_fp64(const BgcPosition2FP64 * position, BgcPosition2FP64 * inverted);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_combine_fp32(const BgcPosition2FP32 * parent, const BgcPosition2FP32 * child, BgcPosition2FP32 * combination);
|
||||||
|
extern inline void bgc_position2_combine_fp64(const BgcPosition2FP64 * parent, const BgcPosition2FP64 * child, BgcPosition2FP64 * combination);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_get_outward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * outward_affine_map);
|
||||||
|
extern inline void bgc_position2_get_outward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * outward_affine_map);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_get_inward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * inward_affine_map);
|
||||||
|
extern inline void bgc_position2_get_inward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * inward_affine_map);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_transform_point_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_point, BgcVector2FP32 * outer_point);
|
||||||
|
extern inline void bgc_position2_transform_point_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_point, BgcVector2FP64 * outer_point);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_transform_point_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_point, BgcVector2FP32 * inner_point);
|
||||||
|
extern inline void bgc_position2_transform_point_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_point, BgcVector2FP64 * inner_point);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_transform_vector_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_vector, BgcVector2FP32 * outer_vector);
|
||||||
|
extern inline void bgc_position2_transform_vector_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_vector, BgcVector2FP64 * outer_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_position2_transform_vector_inward_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_vector, BgcVector2FP32 * inner_vector);
|
||||||
|
extern inline void bgc_position2_transform_vector_inward_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_vector, BgcVector2FP64 * inner_vector);
|
||||||
215
basic-geometry/position2.h
Normal file
215
basic-geometry/position2.h
Normal file
|
|
@ -0,0 +1,215 @@
|
||||||
|
#ifndef _BGC_POSITION2_H_INCLUDED_
|
||||||
|
#define _BGC_POSITION2_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "vector2.h"
|
||||||
|
#include "affine2.h"
|
||||||
|
#include "cotes-number.h"
|
||||||
|
|
||||||
|
// ==================== Types ==================== //
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BgcCotesNumberFP32 turn;
|
||||||
|
BgcVector2FP32 shift;
|
||||||
|
} BgcPosition2FP32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BgcCotesNumberFP64 turn;
|
||||||
|
BgcVector2FP64 shift;
|
||||||
|
} BgcPosition2FP64;
|
||||||
|
|
||||||
|
// ==================== Reset ==================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_reset_fp32(BgcPosition2FP32 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_reset_fp32(&position->turn);
|
||||||
|
bgc_vector2_reset_fp32(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_reset_fp64(BgcPosition2FP64 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_reset_fp64(&position->turn);
|
||||||
|
bgc_vector2_reset_fp64(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Make ===================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_make_fp32(const BgcCotesNumberFP32 * turn, const BgcVector2FP32 * shift, BgcPosition2FP32 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_copy_fp32(turn, &position->turn);
|
||||||
|
bgc_vector2_copy_fp32(shift, &position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_make_fp64(const BgcCotesNumberFP64 * turn, const BgcVector2FP64 * shift, BgcPosition2FP64 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_copy_fp64(turn, &position->turn);
|
||||||
|
bgc_vector2_copy_fp64(shift, &position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== Copy ===================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_copy_fp32(const BgcPosition2FP32 * source, BgcPosition2FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_copy_fp32(&source->turn, &destination->turn);
|
||||||
|
bgc_vector2_copy_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_copy_fp64(const BgcPosition2FP64 * source, BgcPosition2FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_copy_fp64(&source->turn, &destination->turn);
|
||||||
|
bgc_vector2_copy_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Convert =================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_convert_fp64_to_fp32(const BgcPosition2FP64 * source, BgcPosition2FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_convert_fp64_to_fp32(&source->turn, &destination->turn);
|
||||||
|
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_convert_fp32_to_fp64(const BgcPosition2FP32 * source, BgcPosition2FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_convert_fp32_to_fp64(&source->turn, &destination->turn);
|
||||||
|
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Invert ==================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_invert_fp32(BgcPosition2FP32 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &position->shift, &position->shift);
|
||||||
|
bgc_cotes_number_invert_fp32(&position->turn);
|
||||||
|
bgc_vector2_make_opposite_fp32(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_invert_fp64(BgcPosition2FP64 * position)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &position->shift, &position->shift);
|
||||||
|
bgc_cotes_number_invert_fp64(&position->turn);
|
||||||
|
bgc_vector2_make_opposite_fp64(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Get Inverse ================= //
|
||||||
|
|
||||||
|
inline void bgc_position2_get_inverse_fp32(const BgcPosition2FP32 * position, BgcPosition2FP32 * inverted)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &position->shift, &inverted->shift);
|
||||||
|
bgc_cotes_number_get_inverse_fp32(&position->turn, &inverted->turn);
|
||||||
|
bgc_vector2_make_opposite_fp32(&inverted->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_get_inverse_fp64(const BgcPosition2FP64 * position, BgcPosition2FP64 * inverted)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &position->shift, &inverted->shift);
|
||||||
|
bgc_cotes_number_get_inverse_fp64(&position->turn, &inverted->turn);
|
||||||
|
bgc_vector2_make_opposite_fp64(&inverted->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Combine =================== //
|
||||||
|
|
||||||
|
inline void bgc_position2_combine_fp32(const BgcPosition2FP32 * parent, const BgcPosition2FP32 * child, BgcPosition2FP32 * combination)
|
||||||
|
{
|
||||||
|
BgcVector2FP32 relative_shift;
|
||||||
|
bgc_cotes_number_turn_vector_fp32(&parent->turn, &child->shift, &relative_shift);
|
||||||
|
bgc_cotes_number_combine_fp32(&child->turn, &parent->turn, &combination->turn);
|
||||||
|
bgc_vector2_add_fp32(&parent->shift, &relative_shift, &combination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_combine_fp64(const BgcPosition2FP64 * parent, const BgcPosition2FP64 * child, BgcPosition2FP64 * combination)
|
||||||
|
{
|
||||||
|
BgcVector2FP64 relative_shift;
|
||||||
|
bgc_cotes_number_turn_vector_fp64(&parent->turn, &child->shift, &relative_shift);
|
||||||
|
bgc_cotes_number_combine_fp64(&child->turn, &parent->turn, &combination->turn);
|
||||||
|
bgc_vector2_add_fp64(&parent->shift, &relative_shift, &combination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============= Get Outward Affine ============== //
|
||||||
|
|
||||||
|
inline void bgc_position2_get_outward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * outward_affine_map)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_get_rotation_matrix_fp32(&position->turn, &outward_affine_map->distortion);
|
||||||
|
bgc_vector2_copy_fp32(&position->shift, &outward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_get_outward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * outward_affine_map)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_get_rotation_matrix_fp64(&position->turn, &outward_affine_map->distortion);
|
||||||
|
bgc_vector2_copy_fp64(&position->shift, &outward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============== Get Inward Affine ============== //
|
||||||
|
|
||||||
|
inline void bgc_position2_get_inward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * inward_affine_map)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_get_reverse_matrix_fp32(&position->turn, &inward_affine_map->distortion);
|
||||||
|
bgc_matrix2x2_get_right_product_fp32(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
|
||||||
|
bgc_vector2_make_opposite_fp32(&inward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_get_inward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * inward_affine_map)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_get_reverse_matrix_fp64(&position->turn, &inward_affine_map->distortion);
|
||||||
|
bgc_matrix2x2_get_right_product_fp64(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
|
||||||
|
bgc_vector2_make_opposite_fp64(&inward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Transform Point Outwards =========== //
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_point_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_point, BgcVector2FP32 * outer_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP32 turned_point;
|
||||||
|
bgc_cotes_number_turn_vector_fp32(&position->turn, inner_point, &turned_point);
|
||||||
|
bgc_vector2_add_fp32(&position->shift, &turned_point, outer_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_point_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_point, BgcVector2FP64 * outer_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP64 turned_point;
|
||||||
|
bgc_cotes_number_turn_vector_fp64(&position->turn, inner_point, &turned_point);
|
||||||
|
bgc_vector2_add_fp64(&position->shift, &turned_point, outer_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== Transform Point Inwards =========== //
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_point_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_point, BgcVector2FP32 * inner_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP32 relative_point;
|
||||||
|
bgc_vector2_subtract_fp32(outer_point, &position->shift, &relative_point);
|
||||||
|
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &relative_point, inner_point);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_point_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_point, BgcVector2FP64 * inner_point)
|
||||||
|
{
|
||||||
|
BgcVector2FP64 relative_point;
|
||||||
|
bgc_vector2_subtract_fp64(outer_point, &position->shift, &relative_point);
|
||||||
|
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &relative_point, inner_point);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Transform Vector Outwards ========== //
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_vector_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_vector, BgcVector2FP32 * outer_vector)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_fp32(&position->turn, inner_vector, outer_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_vector_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_vector, BgcVector2FP64 * outer_vector)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_fp64(&position->turn, inner_vector, outer_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Transform Vector Inwards =========== //
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_vector_inward_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_vector, BgcVector2FP32 * inner_vector)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp32(&position->turn, outer_vector, inner_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position2_transform_vector_inward_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_vector, BgcVector2FP64 * inner_vector)
|
||||||
|
{
|
||||||
|
bgc_cotes_number_turn_vector_back_fp64(&position->turn, outer_vector, inner_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -6,8 +6,35 @@ extern inline void bgc_position3_reset_fp64(BgcPosition3FP64 * node);
|
||||||
extern inline void bgc_position3_make_fp32(const BgcVersorFP32 * turn, const BgcVector3FP32 * shift, BgcPosition3FP32 * position);
|
extern inline void bgc_position3_make_fp32(const BgcVersorFP32 * turn, const BgcVector3FP32 * shift, BgcPosition3FP32 * position);
|
||||||
extern inline void bgc_position3_make_fp64(const BgcVersorFP64 * turn, const BgcVector3FP64 * shift, BgcPosition3FP64 * position);
|
extern inline void bgc_position3_make_fp64(const BgcVersorFP64 * turn, const BgcVector3FP64 * shift, BgcPosition3FP64 * position);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_copy_fp32(const BgcPosition3FP32 * source, BgcPosition3FP32 * destination);
|
||||||
|
extern inline void bgc_position3_copy_fp64(const BgcPosition3FP64 * source, BgcPosition3FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_convert_fp64_to_fp32(const BgcPosition3FP64 * source, BgcPosition3FP32 * destination);
|
||||||
|
extern inline void bgc_position3_convert_fp32_to_fp64(const BgcPosition3FP32 * source, BgcPosition3FP64 * destination);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_invert_fp32(BgcPosition3FP32 * position);
|
||||||
|
extern inline void bgc_position3_invert_fp64(BgcPosition3FP64 * position);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_get_inverse_fp32(const BgcPosition3FP32 * position, BgcPosition3FP32 * inverted);
|
||||||
|
extern inline void bgc_position3_get_inverse_fp64(const BgcPosition3FP64 * position, BgcPosition3FP64 * inverted);
|
||||||
|
|
||||||
extern inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * parent, const BgcPosition3FP32 * child, BgcPosition3FP32 * combination);
|
extern inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * parent, const BgcPosition3FP32 * child, BgcPosition3FP32 * combination);
|
||||||
extern inline void bgc_position3_combine_fp64(const BgcPosition3FP64 * parent, const BgcPosition3FP64 * child, BgcPosition3FP64 * combination);
|
extern inline void bgc_position3_combine_fp64(const BgcPosition3FP64 * parent, const BgcPosition3FP64 * child, BgcPosition3FP64 * combination);
|
||||||
|
|
||||||
extern inline void bgc_position3_get_affine3_map_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * affine_map);
|
extern inline void bgc_position3_get_outward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * outward_affine_map);
|
||||||
extern inline void bgc_position3_get_affine3_map_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * affine_map);
|
extern inline void bgc_position3_get_outward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * outward_affine_map);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_get_inward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * inward_affine_map);
|
||||||
|
extern inline void bgc_position3_get_inward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * inward_affine_map);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_transform_point_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_point, BgcVector3FP32 * outer_point);
|
||||||
|
extern inline void bgc_position3_transform_point_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_point, BgcVector3FP64 * outer_point);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_transform_point_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_point, BgcVector3FP32 * inner_point);
|
||||||
|
extern inline void bgc_position3_transform_point_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_point, BgcVector3FP64 * inner_point);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_transform_vector_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_vector, BgcVector3FP32 * outer_vector);
|
||||||
|
extern inline void bgc_position3_transform_vector_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_vector, BgcVector3FP64 * outer_vector);
|
||||||
|
|
||||||
|
extern inline void bgc_position3_transform_vector_inward_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_vector, BgcVector3FP32 * inner_vector);
|
||||||
|
extern inline void bgc_position3_transform_vector_inward_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_vector, BgcVector3FP64 * inner_vector);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,66 @@ inline void bgc_position3_make_fp64(const BgcVersorFP64 * turn, const BgcVector3
|
||||||
bgc_vector3_copy_fp64(shift, &position->shift);
|
bgc_vector3_copy_fp64(shift, &position->shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== Copy ===================== //
|
||||||
|
|
||||||
|
inline void bgc_position3_copy_fp32(const BgcPosition3FP32 * source, BgcPosition3FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_versor_copy_fp32(&source->turn, &destination->turn);
|
||||||
|
bgc_vector3_copy_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_copy_fp64(const BgcPosition3FP64 * source, BgcPosition3FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_versor_copy_fp64(&source->turn, &destination->turn);
|
||||||
|
bgc_vector3_copy_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Convert =================== //
|
||||||
|
|
||||||
|
inline void bgc_position3_convert_fp64_to_fp32(const BgcPosition3FP64 * source, BgcPosition3FP32 * destination)
|
||||||
|
{
|
||||||
|
bgc_versor_convert_fp64_to_fp32(&source->turn, &destination->turn);
|
||||||
|
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_convert_fp32_to_fp64(const BgcPosition3FP32 * source, BgcPosition3FP64 * destination)
|
||||||
|
{
|
||||||
|
bgc_versor_convert_fp32_to_fp64(&source->turn, &destination->turn);
|
||||||
|
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Invert ==================== //
|
||||||
|
|
||||||
|
inline void bgc_position3_invert_fp32(BgcPosition3FP32 * position)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp32(&position->turn, &position->shift, &position->shift);
|
||||||
|
bgc_versor_invert_fp32(&position->turn);
|
||||||
|
bgc_vector3_make_opposite_fp32(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_invert_fp64(BgcPosition3FP64 * position)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp64(&position->turn, &position->shift, &position->shift);
|
||||||
|
bgc_versor_invert_fp64(&position->turn);
|
||||||
|
bgc_vector3_make_opposite_fp64(&position->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Get Inverse ================= //
|
||||||
|
|
||||||
|
inline void bgc_position3_get_inverse_fp32(const BgcPosition3FP32 * position, BgcPosition3FP32 * inverted)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp32(&position->turn, &position->shift, &inverted->shift);
|
||||||
|
bgc_versor_get_inverse_fp32(&position->turn, &inverted->turn);
|
||||||
|
bgc_vector3_make_opposite_fp32(&inverted->shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_get_inverse_fp64(const BgcPosition3FP64 * position, BgcPosition3FP64 * inverted)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp64(&position->turn, &position->shift, &inverted->shift);
|
||||||
|
bgc_versor_get_inverse_fp64(&position->turn, &inverted->turn);
|
||||||
|
bgc_vector3_make_opposite_fp64(&inverted->shift);
|
||||||
|
}
|
||||||
|
|
||||||
// =================== Combine =================== //
|
// =================== Combine =================== //
|
||||||
|
|
||||||
inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * parent, const BgcPosition3FP32 * child, BgcPosition3FP32 * combination)
|
inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * parent, const BgcPosition3FP32 * child, BgcPosition3FP32 * combination)
|
||||||
|
|
@ -63,78 +123,92 @@ inline void bgc_position3_combine_fp64(const BgcPosition3FP64 * parent, const Bg
|
||||||
bgc_vector3_add_fp64(&parent->shift, &relative_shift, &combination->shift);
|
bgc_vector3_add_fp64(&parent->shift, &relative_shift, &combination->shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Get Affine ================== //
|
// ============= Get Outward Affine ============== //
|
||||||
|
|
||||||
inline void bgc_position3_get_affine3_map_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * affine_map)
|
inline void bgc_position3_get_outward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * outward_affine_map)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
bgc_versor_get_rotation_matrix_fp32(&position->turn, &outward_affine_map->distortion);
|
||||||
bgc_versor_get_rotation_matrix_fp32(&position->turn, &affine_map->distortion);
|
bgc_vector3_copy_fp32(&position->shift, &outward_affine_map->shift);
|
||||||
bgc_vector3_copy_fp32(&position->shift, &affine_map->shift);
|
|
||||||
#else
|
|
||||||
const float s0s0 = position->turn._s0 * position->turn._s0;
|
|
||||||
const float x1x1 = position->turn._x1 * position->turn._x1;
|
|
||||||
const float x2x2 = position->turn._x2 * position->turn._x2;
|
|
||||||
const float x3x3 = position->turn._x3 * position->turn._x3;
|
|
||||||
|
|
||||||
const float s0x1 = position->turn._s0 * position->turn._x1;
|
|
||||||
const float s0x2 = position->turn._s0 * position->turn._x2;
|
|
||||||
const float s0x3 = position->turn._s0 * position->turn._x3;
|
|
||||||
const float x1x2 = position->turn._x1 * position->turn._x2;
|
|
||||||
const float x1x3 = position->turn._x1 * position->turn._x3;
|
|
||||||
const float x2x3 = position->turn._x2 * position->turn._x3;
|
|
||||||
|
|
||||||
affine_map->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
|
||||||
affine_map->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
|
||||||
affine_map->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
|
||||||
|
|
||||||
affine_map->r1c2 = 2.0f * (x1x2 - s0x3);
|
|
||||||
affine_map->r2c3 = 2.0f * (x2x3 - s0x1);
|
|
||||||
affine_map->r3c1 = 2.0f * (x1x3 - s0x2);
|
|
||||||
|
|
||||||
affine_map->r2c1 = 2.0f * (x1x2 + s0x3);
|
|
||||||
affine_map->r3c2 = 2.0f * (x2x3 + s0x1);
|
|
||||||
affine_map->r1c3 = 2.0f * (x1x3 + s0x2);
|
|
||||||
|
|
||||||
affine_map->shift1 = position->shift.x1;
|
|
||||||
affine_map->shift2 = position->shift.x2;
|
|
||||||
affine_map->shift3 = position->shift.x3;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_position3_get_affine3_map_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * affine_map)
|
inline void bgc_position3_get_outward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * outward_affine_map)
|
||||||
{
|
{
|
||||||
#if BGC_AFFINE_USE_MATRIX
|
bgc_versor_get_rotation_matrix_fp64(&position->turn, &outward_affine_map->distortion);
|
||||||
bgc_versor_get_rotation_matrix_fp64(&position->turn, &affine_map->distortion);
|
bgc_vector3_copy_fp64(&position->shift, &outward_affine_map->shift);
|
||||||
bgc_vector3_copy_fp64(&position->shift, &affine_map->shift);
|
}
|
||||||
#else
|
|
||||||
const double s0s0 = position->turn._s0 * position->turn._s0;
|
|
||||||
const double x1x1 = position->turn._x1 * position->turn._x1;
|
|
||||||
const double x2x2 = position->turn._x2 * position->turn._x2;
|
|
||||||
const double x3x3 = position->turn._x3 * position->turn._x3;
|
|
||||||
|
|
||||||
const double s0x1 = position->turn._s0 * position->turn._x1;
|
// ============== Get Inward Affine ============== //
|
||||||
const double s0x2 = position->turn._s0 * position->turn._x2;
|
|
||||||
const double s0x3 = position->turn._s0 * position->turn._x3;
|
|
||||||
const double x1x2 = position->turn._x1 * position->turn._x2;
|
|
||||||
const double x1x3 = position->turn._x1 * position->turn._x3;
|
|
||||||
const double x2x3 = position->turn._x2 * position->turn._x3;
|
|
||||||
|
|
||||||
affine_map->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
inline void bgc_position3_get_inward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * inward_affine_map)
|
||||||
affine_map->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
{
|
||||||
affine_map->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
bgc_versor_get_reverse_matrix_fp32(&position->turn, &inward_affine_map->distortion);
|
||||||
|
bgc_matrix3x3_get_right_product_fp32(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
|
||||||
|
bgc_vector3_make_opposite_fp32(&inward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
affine_map->r1c2 = 2.0 * (x1x2 - s0x3);
|
inline void bgc_position3_get_inward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * inward_affine_map)
|
||||||
affine_map->r2c3 = 2.0 * (x2x3 - s0x1);
|
{
|
||||||
affine_map->r3c1 = 2.0 * (x1x3 - s0x2);
|
bgc_versor_get_reverse_matrix_fp64(&position->turn, &inward_affine_map->distortion);
|
||||||
|
bgc_matrix3x3_get_right_product_fp64(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
|
||||||
|
bgc_vector3_make_opposite_fp64(&inward_affine_map->shift);
|
||||||
|
}
|
||||||
|
|
||||||
affine_map->r2c1 = 2.0 * (x1x2 + s0x3);
|
// ========== Transform Point Outwards =========== //
|
||||||
affine_map->r3c2 = 2.0 * (x2x3 + s0x1);
|
|
||||||
affine_map->r1c3 = 2.0 * (x1x3 + s0x2);
|
|
||||||
|
|
||||||
affine_map->shift1 = position->shift.x1;
|
inline void bgc_position3_transform_point_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_point, BgcVector3FP32 * outer_point)
|
||||||
affine_map->shift2 = position->shift.x2;
|
{
|
||||||
affine_map->shift3 = position->shift.x3;
|
BgcVector3FP32 turned_point;
|
||||||
#endif
|
bgc_versor_turn_vector_fp32(&position->turn, inner_point, &turned_point);
|
||||||
|
bgc_vector3_add_fp32(&position->shift, &turned_point, outer_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_point_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_point, BgcVector3FP64 * outer_point)
|
||||||
|
{
|
||||||
|
BgcVector3FP64 turned_point;
|
||||||
|
bgc_versor_turn_vector_fp64(&position->turn, inner_point, &turned_point);
|
||||||
|
bgc_vector3_add_fp64(&position->shift, &turned_point, outer_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== Transform Point Inwards =========== //
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_point_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_point, BgcVector3FP32 * inner_point)
|
||||||
|
{
|
||||||
|
BgcVector3FP32 relative_point;
|
||||||
|
bgc_vector3_subtract_fp32(outer_point, &position->shift, &relative_point);
|
||||||
|
bgc_versor_turn_vector_back_fp32(&position->turn, &relative_point, inner_point);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_point_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_point, BgcVector3FP64 * inner_point)
|
||||||
|
{
|
||||||
|
BgcVector3FP64 relative_point;
|
||||||
|
bgc_vector3_subtract_fp64(outer_point, &position->shift, &relative_point);
|
||||||
|
bgc_versor_turn_vector_back_fp64(&position->turn, &relative_point, inner_point);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Transform Vector Outwards ========== //
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_vector_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_vector, BgcVector3FP32 * outer_vector)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_fp32(&position->turn, inner_vector, outer_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_vector_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_vector, BgcVector3FP64 * outer_vector)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_fp64(&position->turn, inner_vector, outer_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Transform Vector Inwards =========== //
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_vector_inward_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_vector, BgcVector3FP32 * inner_vector)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp32(&position->turn, outer_vector, inner_vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_position3_transform_vector_inward_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_vector, BgcVector3FP64 * inner_vector)
|
||||||
|
{
|
||||||
|
bgc_versor_turn_vector_back_fp64(&position->turn, outer_vector, inner_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _BGC_POSITION_H_INCLUDED_
|
#endif // _BGC_POSITION_H_INCLUDED_
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,6 @@
|
||||||
#define BGC_AXIS_REVERSE_X2 -2
|
#define BGC_AXIS_REVERSE_X2 -2
|
||||||
#define BGC_AXIS_REVERSE_X3 -3
|
#define BGC_AXIS_REVERSE_X3 -3
|
||||||
|
|
||||||
#if !defined(BGC_AFFINE_USE_MATRIX)
|
|
||||||
#define BGC_AFFINE_USE_MATRIX 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline int bgc_is_correct_axis(const int axis)
|
inline int bgc_is_correct_axis(const int axis)
|
||||||
{
|
{
|
||||||
return axis == BGC_AXIS_X1 || axis == BGC_AXIS_REVERSE_X1
|
return axis == BGC_AXIS_X1 || axis == BGC_AXIS_REVERSE_X1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue