Beispiel #1
0
double gauss_height_fn(char *data,double x,double z)
{
  gauss_info *gi = (gauss_info *) data;
  dyv *xdyv = mk_dyv_2(x,z);
  double result = gauss_eval(xdyv,gi->mu,gi->cov_inv,gi->cov_determinant);
  free_dyv(xdyv);
  return result;
}
/*
 * Given a seg which participates in the partition we are shading evaluate
 * the transmission on the path
 */
static double
eval_seg(struct application *ap, struct reg_db_internals *dbint, struct seg *seg_p)
{
    double span;
    point_t pt;
    struct rt_ell_internal *ell_p = (struct rt_ell_internal *)dbint->ip.idb_ptr;
    double optical_density = 0.0;
    double step_dist;
    double dist;
    int steps;


    /* XXX Should map the ray into the coordinate system of the ellipsoid
     * here, so that all computations are done in an axis-aligned system
     * with the axes being the gaussian dimensions
     */


    span = seg_p->seg_out.hit_dist - seg_p->seg_in.hit_dist;
    steps = (int)(span / 100.0 + 0.5);
    if (steps < 2) steps = 2;

    step_dist = span / (double)steps;


    if (rdebug&RDEBUG_SHADE) {
	bu_log("Evaluating Segment:\n");
	bu_log("dist_in:%g dist_out:%g span:%g step_dist:%g steps:%d\n",
	       seg_p->seg_in.hit_dist,
	       seg_p->seg_out.hit_dist,
	       span, step_dist, steps);

    }

    for (dist=seg_p->seg_in.hit_dist; dist < seg_p->seg_out.hit_dist; dist += step_dist) {
	VJOIN1(pt, ap->a_ray.r_pt, dist, ap->a_ray.r_dir);
	optical_density += gauss_eval(pt, ell_p->v, dbint->one_sigma);
    }

    return optical_density;
}