Пример #1
0
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);
  }
}
Пример #2
0
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;
}
Пример #3
0
/*
** 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;
}