Добавление position3 и aффинного преобразования
This commit is contained in:
parent
fd7c6c91cd
commit
d8347656c7
7 changed files with 375 additions and 0 deletions
13
basic-geometry/affine3.c
Normal file
13
basic-geometry/affine3.c
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "affine3.h"
|
||||||
|
|
||||||
|
extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine);
|
||||||
|
extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * 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_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point);
|
||||||
|
extern inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point);
|
||||||
|
|
||||||
|
extern inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector);
|
||||||
|
extern inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector);
|
||||||
197
basic-geometry/affine3.h
Normal file
197
basic-geometry/affine3.h
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
#ifndef _BGC_AFFINE3_H_INCLUDED_
|
||||||
|
#define _BGC_AFFINE3_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "utilities.h"
|
||||||
|
#include "vector3.h"
|
||||||
|
#include "matrixes.h"
|
||||||
|
#include "matrix3x3.h"
|
||||||
|
|
||||||
|
// ==================== Types ==================== //
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
#if BGC_AFFINE_USE_MATRIX
|
||||||
|
BgcMatrix3x3FP32 distortion;
|
||||||
|
BgcVector3FP32 shift;
|
||||||
|
#else
|
||||||
|
float r1c1, r1c2, r1c3, shift1;
|
||||||
|
float r2c1, r2c2, r2c3, shift2;
|
||||||
|
float r3c1, r3c2, r3c3, shift3;
|
||||||
|
#endif
|
||||||
|
} BgcAffine3FP32;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
#if BGC_AFFINE_USE_MATRIX
|
||||||
|
BgcMatrix3x3FP64 distortion;
|
||||||
|
BgcVector3FP64 shift;
|
||||||
|
#else
|
||||||
|
double r1c1, r1c2, r1c3, shift1;
|
||||||
|
double r2c1, r2c2, r2c3, shift2;
|
||||||
|
double r3c1, r3c2, r3c3, shift3;
|
||||||
|
#endif
|
||||||
|
} BgcAffine3FP64;
|
||||||
|
|
||||||
|
// ==================== Reset ==================== //
|
||||||
|
|
||||||
|
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine)
|
||||||
|
{
|
||||||
|
#if BGC_AFFINE_USE_MATRIX
|
||||||
|
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion);
|
||||||
|
bgc_vector3_reset_fp32(&affine->shift);
|
||||||
|
#else
|
||||||
|
affine->r1c1 = 1.0f;
|
||||||
|
affine->r1c2 = 0.0f;
|
||||||
|
affine->r1c3 = 0.0f;
|
||||||
|
affine->shift1 = 0.0f;
|
||||||
|
|
||||||