|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _AFFINE_H_
|
|
Toshihiro Shimizu |
890ddd |
#define _AFFINE_H_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef TNZAPI
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZ_IS_RASTERLIB
|
|
Toshihiro Shimizu |
890ddd |
#define TNZAPI TNZ_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define TNZAPI TNZ_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef struct { /* to be PRE-multiplied with a COLUMN vector, i.e., */
|
|
Shinya Kitaoka |
120a6e |
double a11, a12, a13; /* x = a11*u + a12*v + a13 */
|
|
Shinya Kitaoka |
120a6e |
double a21, a22, a23; /* y = a21*u + a22*v + a23 */
|
|
Toshihiro Shimizu |
890ddd |
} AFFINE;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define AFF_M_V_1(AFF, V1, V2) ((AFF).a11 * (V1) + (AFF).a12 * (V2) + (AFF).a13)
|
|
Toshihiro Shimizu |
890ddd |
#define AFF_M_V_2(AFF, V1, V2) ((AFF).a21 * (V1) + (AFF).a22 * (V2) + (AFF).a23)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static const AFFINE Aff_I = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_shift(double dx, double dy, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_shift_post(double dx, double dy, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_rot(double degrees, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_scale(double sx, double sy, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_shear(double shx, double shy, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_place(double u, double v, double x, double y, AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_mult(AFFINE aff1, AFFINE aff2);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI AFFINE aff_inv(AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
TNZAPI double aff_det(AFFINE aff);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define AFF_FILL(AFF, A11, A12, A13, A21, A22, A23) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a11 = A11; \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a12 = A12; \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a13 = A13; \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a21 = A21; \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a22 = A22; \
|
|
Shinya Kitaoka |
120a6e |
(AFF).a23 = A23; \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define AFF_EQ(A, B) \
|
|
Shinya Kitaoka |
120a6e |
((A).a11 == (B).a11 && (A).a12 == (B).a12 && (A).a13 == (B).a13 && \
|
|
Shinya Kitaoka |
120a6e |
(A).a21 == (B).a21 && (A).a22 == (B).a22 && (A).a23 == (B).a23)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define AFF_NE(A, B) \
|
|
Shinya Kitaoka |
120a6e |
((A).a11 != (B).a11 || (A).a12 != (B).a12 || (A).a13 != (B).a13 || \
|
|
Shinya Kitaoka |
120a6e |
(A).a21 != (B).a21 || (A).a22 != (B).a22 || (A).a23 != (B).a23)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define ROTATE(ang, cxin, cyin, cxout, cyout, aff) \
|
|
Shinya Kitaoka |
120a6e |
aff_shift(cxout, cyout, aff_rot(ang, aff_shift(-cxin, -cyin, aff)))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define ROTATE_POST(ang, cxin, cyin, cxout, cyout, aff) \
|
|
Shinya Kitaoka |
120a6e |
aff_mult(aff, aff_shift(cxout, cyout, \
|
|
Shinya Kitaoka |
120a6e |
aff_rot(ang, aff_shift(-cxin, -cyin, Aff_I))))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define SCALE(sx, sy, cxin, cyin, cxout, cyout, aff) \
|
|
Shinya Kitaoka |
120a6e |
aff_shift(cxout, cyout, aff_scale(sx, sy, aff_shift(-cxin, -cyin, aff)))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define SCALE_POST(sx, sy, cxin, cyin, cxout, cyout, aff) \
|
|
Shinya Kitaoka |
120a6e |
aff_mult(aff, aff_shift(cxout, cyout, \
|
|
Shinya Kitaoka |
120a6e |
aff_scale(sx, sy, aff_shift(-cxin, -cyin, Aff_I))))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|