00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef CAMERAF_H
00040 #define CAMERAF_H
00041
00042 #ifndef PKGEOM_H
00043 #include "pkgeom.h"
00044 #endif
00045
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049
00050 #ifndef CAMERA_H
00051 #define CPLANE_TOP 0
00052 #define CPLANE_BOTTOM 1
00053 #define CPLANE_LEFT 2
00054 #define CPLANE_RIGHT 3
00055 #define CPLANE_NEAR 4
00056 #define CPLANE_FAR 5
00057 #endif
00058
00059
00060 typedef struct CameraRecf {
00061
00062 boolean parallel;
00063 boolean upside;
00064 boolean c_fixed;
00065
00066 byte magnification;
00067
00068 short xmin, ymin;
00069 short width, height;
00070 float aspect;
00071
00072 point3f position;
00073 float psi, theta, phi;
00074 point3f g_centre;
00075 point3f c_centre;
00076
00077 float xscale, yscale;
00078
00079 trans3f CTr;
00080
00081 trans3f CTrInv;
00082 char ncplanes;
00083 vector4f cplane[6];
00084
00085 float zmin, zmax;
00086 union {
00087 struct {
00088 float f;
00089 float xi0, eta0;
00090 float dxi0, deta0;
00091 } persp;
00092 struct {
00093 float wdt, hgh, diag;
00094 boolean dim_case;
00095 } para;
00096 } vd;
00097
00098 } CameraRecf;
00099
00100
00101 void CameraInitFramef ( CameraRecf *CPos,
00102 boolean parallel, boolean upside,
00103 short width, short height, short xmin, short ymin,
00104 float aspect, int ncplanes );
00105 void CameraSetMagf ( CameraRecf *CPos, byte mag );
00106 void CameraSetDepthRangef ( CameraRecf *CPos, float zmin, float zmax );
00107 void CameraSetMappingf ( CameraRecf *CPos );
00108
00109 void CameraProjectPoint3f ( CameraRecf *CPos, const point3f *p, point3f *q );
00110 void CameraUnProjectPoint3f ( CameraRecf *CPos, const point3f *p, point3f *q );
00111 void CameraProjectPoint2f ( CameraRecf *CPos, const point2f *p, point2f *q );
00112 void CameraUnProjectPoint2f ( CameraRecf *CPos, const point2f *p, point2f *q );
00113 void CameraProjectPoint3Rf ( CameraRecf *CPos, const point4f *p, point3f *q );
00114 void CameraUnProjectPoint3Rf ( CameraRecf *CPos, const point3f *p, float w,
00115 point4f *q );
00116 void CameraProjectPoint2Rf ( CameraRecf *CPos, const point3f *p, point2f *q );
00117 void CameraUnProjectPoint2Rf ( CameraRecf *CPos, const point2f *p, float w,
00118 point3f *q );
00119 void CameraProjectPoint3f2s ( CameraRecf *CPos, const point3f *p, point2s *q );
00120 void CameraProjectPoint3Rf2s ( CameraRecf *CPos, const point4f *p, point2s *q );
00121
00122 void CameraRayOfPixelf ( CameraRecf *CPos, float xi, float eta, ray3f *ray );
00123
00124 void CameraInitPosf ( CameraRecf *CPos );
00125 void CameraSetRotCentref ( CameraRecf *CPos, point3f *centre,
00126 boolean global_coord, boolean global_fixed );
00127 void CameraMoveToGf ( CameraRecf *CPos, point3f *pos );
00128 void CameraTurnGf ( CameraRecf *CPos, float _psi, float _theta, float _phi );
00129 void CameraMoveGf ( CameraRecf *CPos, vector3f *v );
00130 void CameraMoveCf ( CameraRecf *CPos, vector3f *v );
00131 void CameraRotGf ( CameraRecf *CPos, float _psi, float _theta, float _phi );
00132 #define CameraRotXGf(CPos,angle) \
00133 CameraRotGf(CPos, 0.0, (float)(angle), 0.0)
00134 #define CameraRotYGf(CPos,angle) \
00135 CameraRotGf(CPos, (float)(0.5 * PI), (float)(angle), (float)(-0.5 * PI))
00136 #define CameraRotZGf(CPos,angle) \
00137 CameraRotGf(CPos, (float)(angle), 0.0, 0.0)
00138 void CameraRotVGf ( CameraRecf *CPos, vector3f *v, float angle );
00139 void CameraRotCf ( CameraRecf *CPos, float, float, float );
00140 #define CameraRotXCf(CPos,angle) \
00141 CameraRotCf ( CPos, 0.0, (float)(angle), 0.0 )
00142 #define CameraRotYCf(CPos,angle) \
00143 CameraRotCf ( CPos, (float)(0.5 * PI), (float)(angle), (float)(-0.5 * PI) )
00144 #define CameraRotZCf(CPos,angle) \
00145 CameraRotCf ( CPos, (float)(angle), 0.0, 0.0 )
00146 void CameraRotVCf ( CameraRecf *CPos, vector3f *v, float angle );
00147 void CameraSetFf ( CameraRecf *CPos, float f );
00148 void CameraZoomf ( CameraRecf *CPos, float fchange );
00149
00150
00151 boolean CameraClipPoint3f ( CameraRecf *CPos, point3f *p, point3f *q );
00152
00153 boolean CameraClipLine3f ( CameraRecf *CPos,
00154 point3f *p0, float t0, point3f *p1, float t1,
00155 point3f *q0, point3f *q1 );
00156
00157 boolean CameraClipPolygon3f ( CameraRecf *CPos, int n, const point3f *p,
00158 void (*output)(int n, point3f *p) );
00159
00160
00161
00162
00163 boolean Pixel2Spacef ( CameraRecf *CPos, float x, float y, vector3f *n,
00164 point3f *p, point3f *q,
00165 boolean global_in, boolean global_out );
00166
00167 typedef struct PixHLine_detf {
00168 float D, Dt, Dz, Ds, Dts;
00169 } PixHLine_detf;
00170
00171 boolean PixHLine2Spacef ( CameraRecf *CPos, int xi1, int xi2,
00172 int eta, vector3f *n, point3f *p, point3f *p1,
00173 point3f *p2, PixHLine_detf *det );
00174
00175 #ifdef __cplusplus
00176 }
00177 #endif
00178
00179 #endif
00180