euspqp.c
Go to the documentation of this file.
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 #pragma init (register_euspqp)
00026 
00027 #include "eus.h"
00028 
00029 extern pointer ___euspqp();
00030 static register_euspqp()
00031 { add_module_initializer("___euspqp", ___euspqp);}
00032 
00033 extern eusinteger_t PQP_MakeModel();
00034 extern void PQP_DeleteModel(eusinteger_t m);
00035 extern int PQP_BeginModel(eusinteger_t m);
00036 extern int PQP_EndModel(eusinteger_t m);
00037 extern int PQP_AddTri(eusinteger_t m, double p1[], double p2[], double p3[],
00038                       int flag);
00039 extern int PQP_Collide(double R1[3][3], double T1[3], eusinteger_t PQP_Model1,
00040                        double R2[3][3], double T2[3], eusinteger_t PQP_Model2,
00041                        int flag);
00042 extern double PQP_Distance(double R1[3][3], double T1[3], eusinteger_t* PQP_Model1,
00043                            double R2[3][3], double T2[3], eusinteger_t* PQP_Model2,
00044                            double *P1, double *P2, int qsize);
00045 
00046 pointer PQPMAKEMODEL(register context *ctx, int n, register pointer *argv)
00047 {
00048     eusinteger_t addr = PQP_MakeModel();
00049     return makeint(addr);
00050 }
00051 
00052 pointer PQPDELETEMODEL(register context *ctx, int n, register pointer *argv)
00053 {
00054     eusinteger_t m = intval(argv[0]);
00055     PQP_DeleteModel(m);
00056     return(NIL);
00057 }
00058 
00059 pointer PQPBEGINMODEL(register context *ctx, int n, register pointer *argv)
00060 {
00061     eusinteger_t m = intval(argv[0]);
00062     PQP_BeginModel(m);
00063     return(NIL);
00064 }
00065 
00066 pointer PQPENDMODEL(register context *ctx, int n, register pointer *argv)
00067 {
00068     eusinteger_t m = intval(argv[0]);
00069     PQP_EndModel(m);
00070     return(NIL);
00071 }
00072 
00073 pointer PQPADDTRI(register context *ctx, int n, register pointer *argv)
00074 {
00075     eusinteger_t m = intval(argv[0]);
00076     eusfloat_t *fv1=argv[1]->c.fvec.fv;
00077     eusfloat_t *fv2=argv[2]->c.fvec.fv;
00078     eusfloat_t *fv3=argv[3]->c.fvec.fv;
00079     int id = (int)argv[4]>>2;
00080     double dv1[3], dv2[3], dv3[3];
00081     dv1[0] = fv1[0]; dv1[1] = fv1[1]; dv1[2] = fv1[2]; 
00082     dv2[0] = fv2[0]; dv2[1] = fv2[1]; dv2[2] = fv2[2]; 
00083     dv3[0] = fv3[0]; dv3[1] = fv3[1]; dv3[2] = fv3[2];
00084     #if 0
00085     printf("#f(%f %f %f), #f(%f %f %f), #f(%f %f %f), %d\n",
00086            dv1[0], dv1[1], dv1[2], 
00087            dv2[0], dv2[1], dv2[2], 
00088            dv3[0], dv3[1], dv3[2], id);
00089     #endif
00090     PQP_AddTri(m, dv1, dv2, dv3, id);
00091     return(NIL);
00092 }
00093 
00094 pointer PQPCOLLIDE(register context *ctx, int n, register pointer *argv)
00095 {
00096     eusfloat_t *fr1=argv[0]->c.ary.entity->c.fvec.fv;
00097     eusfloat_t *ft1=argv[1]->c.fvec.fv;
00098     eusinteger_t m1=intval(argv[2]);
00099     eusfloat_t *fr2=argv[3]->c.ary.entity->c.fvec.fv;
00100     eusfloat_t *ft2=argv[4]->c.fvec.fv;
00101     eusinteger_t m2=intval(argv[5]);
00102     int flag=(int)argv[6]>>2;
00103     double dr1[3][3], dr2[3][3], dt1[3], dt2[3];
00104 
00105     /*printf("addr1=0x%x, addr2=0x%x, flag=%d\n", m1>>2, m2>>2, flag);*/
00106     
00107     dr1[0][0] = fr1[0]; dr1[0][1] = fr1[1]; dr1[0][2] = fr1[2]; 
00108     dr1[1][0] = fr1[3]; dr1[1][1] = fr1[4]; dr1[1][2] = fr1[5]; 
00109     dr1[2][0] = fr1[6]; dr1[2][1] = fr1[7]; dr1[2][2] = fr1[8];
00110 #if 0
00111     printf("%f %f %f\n %f %f %f\n %f %f %f\n\n",
00112            dr1[0][0], dr1[0][1], dr1[0][2], 
00113            dr1[1][0], dr1[1][1], dr1[1][2], 
00114            dr1[2][0], dr1[2][1], dr1[2][2]);
00115 #endif    
00116     dt1[0] = ft1[0]; dt1[1] = ft1[1]; dt1[2] = ft1[2];
00117 
00118     /*printf("%f %f %f\n", dt1[0], dt1[1], dt1[2]);*/
00119     
00120     dr2[0][0] = fr2[0]; dr2[0][1] = fr2[1]; dr2[0][2] = fr2[2]; 
00121     dr2[1][0] = fr2[3]; dr2[1][1] = fr2[4]; dr2[1][2] = fr2[5]; 
00122     dr2[2][0] = fr2[6]; dr2[2][1] = fr2[7]; dr2[2][2] = fr2[8]; 
00123 
00124     dt2[0] = ft2[0]; dt2[1] = ft2[1]; dt2[2] = ft2[2]; 
00125 
00126     return makeint((eusfloat_t)(PQP_Collide(dr1, dt1, m1, dr2, dt2, m2, flag)));
00127 }
00128 
00129 pointer PQPDISTANCE(register context *ctx, int n, register pointer *argv)
00130 {
00131     eusfloat_t *fr1=argv[0]->c.ary.entity->c.fvec.fv;
00132     eusfloat_t *ft1=argv[1]->c.fvec.fv;
00133     eusinteger_t m1=intval(argv[2]);
00134     eusfloat_t *fr2=argv[3]->c.ary.entity->c.fvec.fv;
00135     eusfloat_t *ft2=argv[4]->c.fvec.fv;
00136     eusinteger_t m2=intval(argv[5]);
00137     eusfloat_t *p1=argv[6]->c.fvec.fv;
00138     eusfloat_t *p2=argv[7]->c.fvec.fv;
00139     double dr1[3][3], dr2[3][3], dt1[3], dt2[3];
00140     int qsize = 2;
00141     numunion nu;
00142 
00143     if (n == 9) qsize = intval(argv[8]);
00144 
00145     /*printf("addr1=0x%x, addr2=0x%x, flag=%d\n", m1>>2, m2>>2, flag);*/
00146     
00147     dr1[0][0] = fr1[0]; dr1[0][1] = fr1[1]; dr1[0][2] = fr1[2]; 
00148     dr1[1][0] = fr1[3]; dr1[1][1] = fr1[4]; dr1[1][2] = fr1[5]; 
00149     dr1[2][0] = fr1[6]; dr1[2][1] = fr1[7]; dr1[2][2] = fr1[8];
00150 #if 0
00151     printf("%f %f %f\n %f %f %f\n %f %f %f\n\n",
00152            dr1[0][0], dr1[0][1], dr1[0][2], 
00153            dr1[1][0], dr1[1][1], dr1[1][2], 
00154            dr1[2][0], dr1[2][1], dr1[2][2]);
00155 #endif    
00156     dt1[0] = ft1[0]; dt1[1] = ft1[1]; dt1[2] = ft1[2];
00157 
00158     /*printf("%f %f %f\n", dt1[0], dt1[1], dt1[2]);*/
00159     
00160     dr2[0][0] = fr2[0]; dr2[0][1] = fr2[1]; dr2[0][2] = fr2[2]; 
00161     dr2[1][0] = fr2[3]; dr2[1][1] = fr2[4]; dr2[1][2] = fr2[5]; 
00162     dr2[2][0] = fr2[6]; dr2[2][1] = fr2[7]; dr2[2][2] = fr2[8]; 
00163 
00164     dt2[0] = ft2[0]; dt2[1] = ft2[1]; dt2[2] = ft2[2]; 
00165 
00166     double distance, P1[3], P2[3];
00167     distance = PQP_Distance(dr1, dt1, (void *)(m1), dr2, dt2, (void *)(m2), P1, P2, qsize);
00168     p1[0]=P1[0]; p1[1]=P1[1]; p1[2]=P1[2];
00169     p2[0]=P2[0]; p2[1]=P2[1]; p2[2]=P2[2];
00170     return (makeflt(distance));
00171 }
00172 
00173 pointer ___euspqp(register context *ctx, int n, register pointer *argv)
00174 {
00175     pointer mod=argv[0];
00176 
00177     defun(ctx, "PQPMAKEMODEL", mod, PQPMAKEMODEL);
00178     defun(ctx, "PQPDELETEMODEL", mod, PQPDELETEMODEL);
00179     defun(ctx, "PQPBEGINMODEL", mod, PQPBEGINMODEL);
00180     defun(ctx, "PQPENDMODEL", mod, PQPENDMODEL);
00181     defun(ctx, "PQPADDTRI", mod, PQPADDTRI);
00182     defun(ctx, "PQPCOLLIDE", mod, PQPCOLLIDE);
00183     defun(ctx, "PQPDISTANCE", mod, PQPDISTANCE);
00184 }
00185 


jskeus
Author(s): JSK Alumnis
autogenerated on Fri Aug 28 2015 11:15:08