int _echoRayIntx_Instance(RAYINTX_ARGS(Instance)) { echoPos_t a[4], b[4], tmp; echoRay iray; /* ELL_3V_COPY(iray.from, ray->from); ELL_3V_COPY(iray.dir, ray->dir); */ ELL_4V_SET(a, ray->from[0], ray->from[1], ray->from[2], 1); ELL_4MV_MUL(b, obj->Mi, a); ELL_34V_HOMOG(iray.from, b); ELL_4V_SET(a, ray->dir[0], ray->dir[1], ray->dir[2], 0); ELL_4MV_MUL(b, obj->Mi, a); ELL_3V_COPY(iray.dir, b); if (tstate->verbose) { fprintf(stderr, "%s%s: dir (%g,%g,%g)\n%s -- Mi --> " "(%g,%g,%g,%g)\n%s --> (%g,%g,%g)\n", _echoDot(tstate->depth), "_echoRayIntx_Instance", a[0], a[1], a[2], _echoDot(tstate->depth), b[0], b[1], b[2], b[3], _echoDot(tstate->depth), iray.dir[0], iray.dir[1], iray.dir[2]); } iray.neer = ray->neer; iray.faar = ray->faar; iray.shadow = ray->shadow; if (_echoRayIntx[obj->obj->type](intx, &iray, obj->obj, parm, tstate)) { ELL_4V_SET(a, intx->norm[0], intx->norm[1], intx->norm[2], 0); ELL_4MV_TMUL(b, obj->Mi, a); ELL_3V_COPY(intx->norm, b); ELL_3V_NORM(intx->norm, intx->norm, tmp); if (tstate->verbose) { fprintf(stderr, "%s%s: hit a %d (at t=%g) with M == \n", _echoDot(tstate->depth), "_echoRayIntx_Instance", obj->obj->type, intx->t); ell_4m_PRINT(stderr, obj->M); fprintf(stderr, "%s ... (det = %f), and Mi == \n", _echoDot(tstate->depth), ell_4m_DET(obj->M)); ell_4m_PRINT(stderr, obj->Mi); } return AIR_TRUE; } /* else */ return AIR_FALSE; }
void gageShapeItoW(gageShape *shape, double _world[3], double _index[3]) { double world[4], index[4]; ELL_3V_COPY(index, _index); index[3] = 1.0; ELL_4MV_MUL(world, shape->ItoW, index); ELL_3V_SCALE(_world, 1.0/world[3], world); }
void gageShapeWtoI(gageShape *shape, double _index[3], double _world[3]) { double index[4], world[4]; ELL_3V_COPY(world, _world); world[3] = 1.0; ELL_4MV_MUL(index, shape->WtoI, world); ELL_3V_SCALE(_index, 1.0/index[3], index); }
void _echoPosSet(echoPos_t *p3, echoPos_t *matx, echoPos_t *p4) { echoPos_t a[4], b[4]; if (matx) { ELL_4V_SET(a, p4[0], p4[1], p4[2], 1); ELL_4MV_MUL(b, matx, a); ELL_34V_HOMOG(p3, b); } else { ELL_3V_COPY(p3, p4); } }
void gageShapeWtoI(gageShape *shape, double _index[3], double _world[3]) { /* char me[]="gageShapeWtoI"; */ double index[4], world[4]; /* fprintf(stderr, "!%s: hello %p %p %p; %p\n", me, shape, _index, _world, shape->WtoI); */ ELL_3V_COPY(world, _world); world[3] = 1.0; ELL_4MV_MUL(index, shape->WtoI, world); ELL_3V_SCALE(_index, 1.0/index[3], index); }
/* ******** limnPolyDataTransform_f, limnPolyDataTransform_d ** ** transforms a surface (both positions, and normals (if set)) ** by given homogenous transform */ void limnPolyDataTransform_f(limnPolyData *pld, const float homat[16]) { double hovec[4], mat[9], inv[9], norm[3], nmat[9]; unsigned int vertIdx; if (pld && homat) { if (pld->norm) { ELL_34M_EXTRACT(mat, homat); ell_3m_inv_d(inv, mat); ELL_3M_TRANSPOSE(nmat, inv); } else { ELL_3M_IDENTITY_SET(nmat); /* hush unused value compiler warnings */ } for (vertIdx=0; vertIdx<pld->xyzwNum; vertIdx++) { ELL_4MV_MUL(hovec, homat, pld->xyzw + 4*vertIdx); ELL_4V_COPY_TT(pld->xyzw + 4*vertIdx, float, hovec); if (pld->norm) { ELL_3MV_MUL(norm, nmat, pld->norm + 3*vertIdx); ELL_3V_COPY_TT(pld->norm + 3*vertIdx, float, norm); } } }
/* ** bins on boundary now extend to infinity; so the only time this ** returns NULL (indicating error) is for non-existent positions */ pushBin * _pushBinLocate(pushContext *pctx, double *_posWorld) { static const char me[]="_pushBinLocate"; double posWorld[4], posIdx[4]; unsigned int axi, eidx[3], binIdx; if (!ELL_3V_EXISTS(_posWorld)) { biffAddf(PUSH, "%s: non-existent position (%g,%g,%g)", me, _posWorld[0], _posWorld[1], _posWorld[2]); return NULL; } if (pctx->binSingle) { binIdx = 0; } else { ELL_3V_COPY(posWorld, _posWorld); posWorld[3] = 1.0; ELL_4MV_MUL(posIdx, pctx->gctx->shape->WtoI, posWorld); ELL_34V_HOMOG(posIdx, posIdx); for (axi=0; axi<3; axi++) { eidx[axi] = airIndexClamp(-0.5, posIdx[axi], pctx->gctx->shape->size[axi]-0.5, pctx->binsEdge[axi]); } binIdx = (eidx[0] + pctx->binsEdge[0]*(eidx[1] + pctx->binsEdge[1]*eidx[2])); } /* fprintf(stderr, "!%s: bin(%g,%g,%g) = %u\n", me, _posWorld[0], _posWorld[1], _posWorld[2], binIdx); */ return pctx->bin + binIdx; }
void ell_4mv_mul_d(double v2[4], double m[16], double v1[4]) { ELL_4MV_MUL(v2, m, v1); }
void ell_4mv_mul_f(float v2[4], float m[16], float v1[4]) { ELL_4MV_MUL(v2, m, v1); }