Exemplo n.º 1
0
double checkReactions(gsl_vector *haz, gsl_vector *residuals, gsl_vector *fast_params, 
                      double deltat,  gsl_vector *sps, gsl_matrix *PostPre)
{
  int i;
  double small_residual = -1000000.0;

  double total_hazard = 0.0;
  for(i=0; i < fast_params->size; i++) {
    if(checkHazard(haz, PostPre, sps, i, deltat) && 
       checkSpecies(PostPre, sps, i))  {
      VSET(residuals, i, small_residual);
    } else if(VGET(residuals, i) < (small_residual + 10000))  {
      total_hazard += VGET(haz, i);
      VSET(residuals, i, log(gsl_ran_flat(r, 0.0, 1.0)));
      VSET(fast_params, i, 0.0);
      //      running_totals1[i]++;
    } else {
      total_hazard += VGET(haz, i);
      VSET(fast_params, i, 0.0);
      //      running_totals1[i]++;
    }
    //printf("%d ", running_totals1[i]);
  }
  //  printf("\n");
  return total_hazard;        
}
Exemplo n.º 2
0
void
render_flos_work(render_t *render, struct tie_s *tie, struct tie_ray_s *ray, vect_t *pixel) {
    struct tie_id_s id, tid;
    vect_t vec;
    fastf_t angle;
    struct render_flos_s *rd;

    rd = (struct render_flos_s *)render->data;

    if (tie_work(tie, ray, &id, render_hit, NULL) != NULL) {
	VSET(*pixel, 0.0, 0.5, 0.0);
    } else
	return;

    VSUB2(vec, ray->pos, id.pos);
    VUNITIZE(vec);
    angle = VDOT(vec, id.norm);

    /* Determine if direct line of sight to fragment */
    VMOVE(ray->pos, rd->frag_pos);
    VSUB2(ray->dir, id.pos, rd->frag_pos);
    VUNITIZE(ray->dir);

    if (tie_work(tie, ray, &tid, render_hit, NULL)) {
	if (fabs (id.pos[0] - tid.pos[0]) < TIE_PREC
	    && fabs (id.pos[1] - tid.pos[1]) < TIE_PREC
	    && fabs (id.pos[2] - tid.pos[2]) < TIE_PREC)
	{
	    VSET(*pixel, 1.0, 0.0, 0.0);
	}
    }

    VSCALE(*pixel, *pixel, (0.5+angle*0.5));
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
    point_t	a, b, c, d;
    struct rt_wdb *fp;

    si.magic = RT_NURB_INTERNAL_MAGIC;
    si.nsrf = 0;
    si.srfs = (struct face_g_snurb **)bu_malloc( sizeof(struct face_g_snurb *)*100, "snurb ptrs");

    if ((fp = wdb_fopen(argv[1])) == NULL) {
        bu_log("unable to open new database [%s]\n", argv[1]);
        perror("unable to open database file");
        return 1;
    }

    mk_id( fp, "Mike's Spline Test" );

    VSET( a,  0,  0,  0 );
    VSET( b, 10,  0,  0 );
    VSET( c, 10, 10,  0 );
    VSET( d,  0, 10,  0 );

    make_face( a, b, c, d, 2 );

    mk_export_fwrite( fp, "spl", (genptr_t)&si, ID_BSPLINE );

    return 0;
}
Exemplo n.º 4
0
double Atmosphere::GADD( lwpp::VolumetricAccess &va, double pp[ 3 ], double y, double falloff,
   int use_lighting, int atmos_type, double li[ 3 ] )
{
   LWItemID light = iteminfo->first( LWI_LIGHT, NULL );
   double ilu[ 3 ], ldir[ 3 ];

   /* accumulate contributions from each light */

   if ( use_lighting && ( va.getFlags() & LWVEF_COLOR )) {
      VSET( li, 0.0 );
      while ( light ) {
         va.illuminate( light, pp, ldir, ilu );
         VADD( li, ilu );
         light = iteminfo->next( light );
      }
   }
   else
      VSET( li, 1.0 );

   /* return GADD (geometric atmospheric density distribution) */

   if ( atmos_type == 1 )
      return exp( -falloff * y );
   else
      return 1.0;
}
Exemplo n.º 5
0
/*
  Hybrid method
*/
void updateHazard(gsl_vector *haz, gsl_vector *params, gsl_vector *sps)
{
  VSET(haz, 0, VGET(params, 0));
  VSET(haz, 1, VGET(params, 1));
  VSET(haz, 2, VGET(params, 2)*VGET(sps, 0));        
  VSET(haz, 3, VGET(params, 3)*VGET(sps, 1));        
  VSET(haz, 4, VGET(params, 4)*VGET(sps, 0)*VGET(sps, 1)); 
}           
void
PL_FORTRAN(f3vect, F3VECT)(FILE **fp, float *fx, float *fy, float *fz, float *tx, float *ty, float *tz, float *fl , float *tl)
{
    point_t from, to;

    VSET(from, *fx, *fy, *fz);
    VSET(to, *tx, *ty, *tz);
    tp_3vector(*fp, from, to, *fl, *tl);
}
Exemplo n.º 7
0
void mvn_sample(gsl_vector *mean_cand, gsl_matrix *var)
{
  /* Takes a mean vec, mean and var matrix, 
   * var and gives vector of MVN(mean,var) realisations, x 
   */
  int i, j;
  int dimen = var -> size1;
  double value;
  gsl_matrix *disp;
  gsl_vector *ran;
  gsl_matrix *fast_species;
  
  fast_species = gsl_matrix_alloc(2, 2);
  gsl_matrix_set_identity(fast_species);
  
  for(i=0;i<dimen; i++) {
    if(MGET(var, i, i) <0.00000000001) {
      MSET(var, i, i, 1.0);
      MSET(fast_species, i, i, 0.0);
    }
  }
  
  disp = gsl_matrix_alloc(2, 2);
  ran = gsl_vector_alloc(2);
  gsl_matrix_memcpy(disp, var);
  if(postive_definite == 1) {
    gsl_linalg_cholesky_decomp(disp);
    for(i=0;i<dimen;i++) {
      for (j=i+1;j<dimen;j++) {
        MSET(disp,i,j,0.0);
      }
    }
  }else{
    value = pow(MGET(disp, 0 ,0), 0.5);
    gsl_matrix_set_identity(disp);
    MSET(disp, 0,0, value);
    MSET(disp, 1,1, value);       
  }

  for (j=0;j<dimen;j++) {
    VSET(ran,j,gsl_ran_gaussian(r,1.0));
  }

  /*remove update from slow species*/
  gsl_matrix_mul_elements(disp, fast_species);
    
  /*Add noise to mean cand*/
  gsl_blas_dgemv(CblasNoTrans,1.0, disp, ran, 1.0, mean_cand);
  for(i=0; i<2; i++)  {
    if(VGET(mean_cand,i)<=0.0001 && MGET(fast_species, i, i) > 0.000001)
      VSET(mean_cand,i,0.0001);
  }
  gsl_vector_free(ran);
  gsl_matrix_free(disp);
  gsl_matrix_free(fast_species);
}
Exemplo n.º 8
0
static void SuperQ_Event( sqData *tool, int code )
{
   switch ( code )
   {
      case LWT_EVENT_DROP:

      /* The drop action is caused when the user clicks in the blank
         area of the display or uses the keyboard equivalent.  If the
         tool is active, we force a rejection of any interactive
         action partly complete.  For inactive tools we drop through
         to the reset action. */

      if ( tool->active ) {
         tool->update = LWT_TEST_REJECT;
         break;
      }

      case LWT_EVENT_RESET:

      /* The reset action corresponds to the reset command on the
         numeric panel, and causes us to snap the SuperQ factor back
         to zero.  Resets are also implicit when the user drops an
         inactive tool, thus the passthru above. */

         tool->nsides = 24;
         tool->nsegments = 12;
         VSET( tool->org, 0.0 );
         VSET( tool->center, 0.0f );
         VSET( tool->holex, 0.0f );
         VSET( tool->holez, 0.0f );
         VSET( tool->rad, 0.5 );
         tool->shape = 0;
         tool->bf1 = 2.0;
         tool->bf2 = 2.0;
         tool->axis = 1;
         tool->diam = 0.50;
         tool->holex[ 0 ] = ( float )( tool->diam * 0.5 );
         tool->holez[ 2 ] = tool->holex[ 0 ];
         tool->update = LWT_TEST_UPDATE;
         tool->dirty = 1;
         setBoxCorners( tool );
         break;

      case LWT_EVENT_ACTIVATE:

      /* Activation can be triggered from the numeric window or with a
         keystroke, and it should restart the edit operation with its
         current settings. */

         tool->update = LWT_TEST_UPDATE;
         tool->active = 1;
         tool->dirty = 1;
         break;
   }
}
Exemplo n.º 9
0
void
bn_mat_lookat(mat_t rot, const vect_t dir, int yflip)
{
    mat_t first;
    mat_t second;
    mat_t prod12;
    mat_t third;
    vect_t x;
    vect_t z;
    vect_t t1;
    fastf_t hypot_xy;
    vect_t xproj;
    vect_t zproj;

    /* First, rotate D around Z axis to match +X axis (azimuth) */
    hypot_xy = hypot(dir[X], dir[Y]);
    bn_mat_zrot(first, -dir[Y] / hypot_xy, dir[X] / hypot_xy);

    /* Next, rotate D around Y axis to match -Z axis (elevation) */
    bn_mat_yrot(second, -hypot_xy, -dir[Z]);
    bn_mat_mul(prod12, second, first);

    /* Produce twist correction, by re-orienting projection of X axis */
    VSET(x, 1, 0, 0);
    MAT4X3VEC(xproj, prod12, x);
    hypot_xy = hypot(xproj[X], xproj[Y]);
    if (hypot_xy < 1.0e-10) {
	bu_log("Warning: bn_mat_lookat:  unable to twist correct, hypot=%g\n", hypot_xy);
	VPRINT("xproj", xproj);
	MAT_COPY(rot, prod12);
	return;
    }
    bn_mat_zrot(third, -xproj[Y] / hypot_xy, xproj[X] / hypot_xy);
    bn_mat_mul(rot, third, prod12);

    if (yflip) {
	VSET(z, 0, 0, 1);
	MAT4X3VEC(zproj, rot, z);
	/* If original Z inverts sign, flip sign on resulting Y */
	if (zproj[Y] < 0.0) {
	    MAT_COPY(prod12, rot);
	    MAT_IDN(third);
	    third[5] = -1;
	    bn_mat_mul(rot, third, prod12);
	}
    }

    /* Check the final results */
    MAT4X3VEC(t1, rot, dir);
    if (t1[Z] > -0.98) {
	bu_log("Error:  bn_mat_lookat final= (%g, %g, %g)\n", V3ARGS(t1));
    }
}
Exemplo n.º 10
0
/* Make a leaf node out of an ARB4 */
void
do_leaf(char *name)
{
    point_t pt[4];

    VSET(pt[0], 0, 0, 0);
    VSET(pt[1], 100, 0, 0);
    VSET(pt[2], 50, 100*sin60, 0);
    VSET(pt[3], 50, 100*sin60/3, 100*sin60);

    mk_arb4(outfp, name, &pt[0][X]);
}
Exemplo n.º 11
0
st_part_at * timingsInitPrior(double X, double Y)
{
  st_part_at *part;
  part = (st_part_at *) malloc(sizeof(st_part_at));
  part->params = gsl_vector_alloc(5);
  part->sps = gsl_vector_alloc(2);
  part->res = gsl_vector_alloc(5);

  VSET(part->sps, 0, X);
  VSET(part->sps, 1, Y);
  return(part);
}    
Exemplo n.º 12
0
int
main(int argc, char *argv[])
{
    point_t a, b, c, d;
    struct rt_wdb *fp;
    struct rt_nurb_internal *si;
    char *filename = "spltest.g";
    int helpflag;

    if (argc < 1 || argc > 2) {
    	printusage(argv);
	bu_exit(1,NULL);
    }

    helpflag = (argc == 2 && ( BU_STR_EQUAL(argv[1],"-h") || BU_STR_EQUAL(argv[1],"-?")));
    if (argc == 1 || helpflag) {
    	printusage(argv);
	if (helpflag)
		bu_exit(1,NULL);
	bu_log("       Program continues running:\n");
    }

    if (argc == 2)
	filename = argv[1];

    if ((fp = wdb_fopen(filename)) == NULL) {
	perror("unable to open geometry database for writing");
	bu_exit(1, "unable to open new database [%s]\n", filename);
    }

    mk_id(fp, "Mike's Spline Test");

    VSET(a,  0,  0,  0);
    VSET(b, 10,  0,  -5);
    VSET(c, 10, 10,  10);
    VSET(d,  0, 10,  0);

    BU_ALLOC(si, struct rt_nurb_internal);
    si->magic = RT_NURB_INTERNAL_MAGIC;
    si->nsrf = 0;
    si->srfs = (struct face_g_snurb **)bu_malloc(sizeof(struct face_g_snurb *)*100, "allocate snurb ptrs");

    make_face(si, a, b, c, d, 2);

    /* wdb_export */
    mk_export_fwrite(fp, "spltest", (void *)si, ID_BSPLINE);
    bu_log("Saving file %s\n",filename);

    return 0;
}
/**
 * Calculate a bounding RPP around a metaball
 */
int
rt_metaball_bbox(struct rt_db_internal *ip, point_t *min, point_t *max, const struct bn_tol *UNUSED(tol))
{
    struct rt_metaball_internal *mb;
    point_t center;
    fastf_t radius;
    mb = (struct rt_metaball_internal *)ip->idb_ptr;
    RT_METABALL_CK_MAGIC(mb);
    VSETALL(center, 0);

    radius = rt_metaball_get_bounding_sphere(&center, mb->threshold, mb);

    VSET((*min), center[X] - radius, center[Y] - radius, center[Z] - radius);
    VSET((*max), center[X] + radius, center[Y] + radius, center[Z] + radius);
    return 0;
}
Exemplo n.º 14
0
/**
 * Returns a vector of the orbital element el for planet pl, built from
 * the list
 * @param kl
 * @param pl
 * @param el
 * @return 
 */
gsl_vector* KL_getElements(const ok_list* kl, const int pl, const int el) {
    gsl_vector* v = gsl_vector_alloc(kl->size);
    
    for (int i = 0; i < kl->size; i++)
        VSET(v, i, MGET(kl->kernels[i]->elements, pl, el));
    return v;
}
Exemplo n.º 15
0
void
bn_wrt_point_direc(mat_t out, const mat_t change, const mat_t in, const point_t point, const vect_t direc, const struct bn_tol *tol)
{
    static mat_t t1;
    static mat_t pt_to_origin, origin_to_pt;
    static mat_t d_to_zaxis, zaxis_to_d;
    static vect_t zaxis;

    /* build "point to origin" matrix */
    MAT_IDN(pt_to_origin);
    MAT_DELTAS_VEC_NEG(pt_to_origin, point);

    /* build "origin to point" matrix */
    MAT_IDN(origin_to_pt);
    MAT_DELTAS_VEC_NEG(origin_to_pt, point);

    /* build "direc to zaxis" matrix */
    VSET(zaxis, 0.0, 0.0, 1.0);
    bn_mat_fromto(d_to_zaxis, direc, zaxis, tol);

    /* build "zaxis to direc" matrix */
    bn_mat_inv(zaxis_to_d, d_to_zaxis);

    /* apply change matrix...
     * t1 = change * d_to_zaxis * pt_to_origin * in
     */
    bn_mat_mul4(t1, change, d_to_zaxis, pt_to_origin, in);

    /* apply origin_to_pt matrix:
     * out = origin_to_pt * zaxis_to_d *
     * change * d_to_zaxis * pt_to_origin * in
     */
    bn_mat_mul3(out, origin_to_pt, zaxis_to_d, t1);
}
Exemplo n.º 16
0
/*
 * Replica of STEP function:
 * FUNCTION build_axes() :
 LIST [3:3] OF direction;
 LOCAL
 d1, d2 : direction;
 END_LOCAL;
 d1 := NVL(normalise(axis), dummy_gri || direction([0.0,0.0,1.0]));
 d2 := first_proj_axis(d1, ref_direction);
 RETURN [d2, normalise(cross_product(d1,d2)).orientation, d1];

 END_FUNCTION;
/////////
*/
void
Axis2Placement3D::BuildAxis() {
    double d1[3] = VINIT_ZERO;
    double d2[3] = VINIT_ZERO;
    double d1Xd2[3] = VINIT_ZERO;

    if (axis == NULL) {
	VSET(d1,0.0,0.0,1.0);
    } else {
	VMOVE(d1,axis->DirectionRatios());
	VUNITIZE(d1);
    }
    if (ref_direction == NULL) {
	FirstProjAxis(d2,d1,NULL);
    } else {
	FirstProjAxis(d2,d1,ref_direction->DirectionRatios());
    }
    VCROSS(d1Xd2,d1,d2);
    VUNITIZE(d1Xd2);
    VMOVE(p[0],d2);
    VMOVE(p[1],d1Xd2);
    VMOVE(p[2],d1);

    return;
}
Exemplo n.º 17
0
Create( void *priv, void *context, LWError *err )
{
   AtmosphereData *dat;

   dat = calloc( 1, sizeof( AtmosphereData ));
   if ( !dat ) {
      *err = "Couldn't allocate instance data.";
      return NULL;
   }

   dat->lo      = -4.0;
   dat->hi      = 0.0;
   dat->fa      = 0.5;
   dat->lum     = 0.5;
   dat->opa     = 1.0;
   dat->den     = 1.0;
   dat->res     = 2;
   dat->type    = 1;
   dat->bck     = 1;
   dat->useTxtr = 0;
   dat->march   = 0;
   VSET( dat->col, 1.0 );

   return dat;
}
Exemplo n.º 18
0
/**
 * Get a summary statistic for the orbital elements; for instance,
 * the median value calculated over all the elements of the list.
 * @param kl List
 * @param what Can be one of: STAT_MEAN, STAT_MEDIAN, STAT_STDDEV, STAT_MAD. 
 *      Summary statistic is calculated correctly for angle parameters.
 * @return A matrix whose entries are the summary statistic for the 
 * corresponding orbital element.
 */
gsl_matrix* KL_getElementsStats(const ok_list* kl, const int what) {
    
    int npl = MROWS(kl->kernels[0]->elements);
    if (npl == 0)
        return NULL;
    
    gsl_vector* v = gsl_vector_alloc(kl->size);
    
    gsl_matrix* m = gsl_matrix_alloc(npl, ALL_ELEMENTS_SIZE);
    gsl_matrix_set_all(m, 0.);
    
    
    for (int i = 0; i < npl; i++)
            for (int j = 0; j < ALL_ELEMENTS_SIZE; j++) {
                for (int n = 0; n < kl->size; n++) {
                    VSET(v, n, MGET(kl->kernels[n]->elements, i, j));
                }
                
                switch (what) {
                    case STAT_MEAN:
                        if (j == MA || j == LOP || j == INC || j == NODE || j == TRUEANOMALY)
                            MSET(m, i, j, ok_average_angle(v->data, v->size, false));
                        else
                            MSET(m, i, j, gsl_stats_mean(v->data, 1, v->size));
                        break;
                    case STAT_STDDEV:
                        if (j == MA || j == LOP || j == INC || j == NODE || j == TRUEANOMALY) {
                            MSET(m, i, j, ok_stddev_angle(v->data, v->size, false));
                        }
                        else
                            MSET(m, i, j, gsl_stats_sd(v->data, 1, v->size));
                        break;
                    case STAT_MEDIAN:
                        if (j == MA || j == LOP || j == INC || j == NODE || j == TRUEANOMALY)
                            MSET(m, i, j, ok_median_angle(v->data, v->size, false));
                        else {
                            gsl_sort_vector(v);
                            MSET(m, i, j, gsl_stats_median_from_sorted_data(v->data, 1, v->size));
                        }
                        break;
                    case STAT_MAD:
                        if (j == MA || j == LOP || j == INC || j == NODE || j == TRUEANOMALY) {
                            double med = ok_median_angle(v->data, v->size, false);
                            MSET(m, i, j, 1.4826 * ok_mad_angle(v->data, v->size, med, false));
                        } else {
                            gsl_sort_vector(v);
                            double med = gsl_stats_median_from_sorted_data(v->data, 1, v->size);
                            
                            MSET(m, i, j, 1.4826 * ok_mad(v->data, v->size, med));
                        }
                        break;
                    default:
                        // percentiles
                        gsl_sort_vector(v);
                        MSET(m, i, j, gsl_stats_quantile_from_sorted_data(v->data, 1, v->size, (double)(what)/100.));
                };
            }
    gsl_vector_free(v);
    return m;
}
Exemplo n.º 19
0
HIDDEN int
ckr_render(struct application *ap, const struct partition *pp, register struct shadework *swp, void *dp)
{
    register struct ckr_specific *ckp =
	(struct ckr_specific *)dp;
    register int *cp;
    int u, v;

    u = swp->sw_uv.uv_u * ckp->ckr_scale;
    v = swp->sw_uv.uv_v * ckp->ckr_scale;

    if (((u&1) && (v&1)) || (!(u&1) && !(v&1))) {
	cp = ckp->ckr_a;
    } else {
	cp = ckp->ckr_b;
    }

    VSET(swp->sw_color,
	 (unsigned char)cp[0] / 255.0,
	 (unsigned char)cp[1] / 255.0,
	 (unsigned char)cp[2] / 255.0);

    if (swp->sw_reflect > 0 || swp->sw_transmit > 0)
	(void)rr_render(ap, pp, swp);

    return 1;
}
Exemplo n.º 20
0
void
Readpoints(void)
{
    struct points *ptr, *prev;
    fastf_t x, y, z;

    ptr = root;
    prev = NULL;


    printf( "X Y Z (^D for end): ");
    while (scanf("%lf%lf%lf", &x, &y, &z) ==  3 )
    {
	if ( ptr == NULL )
	{
	    ptr = (struct points *)bu_malloc( sizeof( struct points ), "ptr" );
	    root = ptr;
	}
	else
	{
	    ptr->next = (struct points *)bu_malloc( sizeof( struct points ), "ptr->next" );
	    ptr = ptr->next;
	}
	ptr->next = NULL;
	ptr->prev = prev;
	prev = ptr;
	VSET(ptr->p, k*x, k*y, k*z);
	ptr->tube[0] = '\0';
	ptr->tubflu[0] = '\0';
	ptr->elbow[0] = '\0';
	ptr->elbflu[0] = '\0';
	ptr->cut[0] = '\0';
	printf( "X Y Z (^D for end): ");
    }
}
Exemplo n.º 21
0
/**
 * Constructs world-to-local space rotation matrix using the up, 
 * right, forward vectors.
 *
 * @param iteminfo	LWItemInfo pointer
 * @param id		Item
 * @param time		Evaluation time
 * @param M			Result in Matrix form
 */
void LWMAT_getWorldRotMatrix(LWItemInfo *iteminfo, 
						LWItemID id,
						LWTime time,
						LWFMatrix4 M)
{
	int i;
	LWDVector up, right, forward;

	iteminfo->param( id, LWIP_W_RIGHT,		time, right);
	iteminfo->param( id, LWIP_W_UP,			time, up);
	iteminfo->param( id, LWIP_W_FORWARD,	time, forward);

	for(i=0; i < 3; i++)
	{
		M[0][i] = right[i];
		M[1][i] = up[i];
		M[2][i] = forward[i];
	}

	// zero out position
	VSET(M[3], 0.0f);

	M[0][3] = 0.0f;
	M[1][3] = 0.0f;
	M[2][3] = 0.0f;
	M[3][3] = 1.0f;
}
Exemplo n.º 22
0
void
render_surfel_work(render_t *render, struct tie_s *tie, struct tie_ray_s *ray, vect_t *pixel)
{
    render_surfel_t *d;
    struct tie_id_s id;
    uint32_t i;
    fastf_t dist_sq;

    d = (render_surfel_t *)render->data;

    if (tie_work(tie, ray, &id, render_hit, NULL) != NULL) {
	for (i = 0; i < d->num; i++) {
	    dist_sq = (d->list[i].pos[0]-id.pos[0]) * (d->list[i].pos[0]-id.pos[0]) +
		(d->list[i].pos[1]-id.pos[1]) * (d->list[i].pos[1]-id.pos[1]) +
		(d->list[i].pos[2]-id.pos[2]) * (d->list[i].pos[2]-id.pos[2]);

	    if (dist_sq < d->list[i].radius*d->list[i].radius) {
		VMOVE(*pixel, d->list[i].color);
		break;
	    }
	}

	VSET(*pixel, 0.8, 0.8, 0.8);
    }
}
Exemplo n.º 23
0
void
draw_v_axes()
{
    point_t v_ap;			/* axes position in view coordinates */

    VSET(v_ap,
	 axes_state->ax_view_pos[X] * INV_GED,
	 axes_state->ax_view_pos[Y] * INV_GED / dmp->dm_aspect,
	 0.0);

    dmo_drawAxes_cmd(dmp,
		     view_state->vs_vop->vo_size,
		     view_state->vs_vop->vo_rotation,
		     v_ap,
		     axes_state->ax_view_size * INV_GED,
		     color_scheme->cs_view_axes,
		     color_scheme->cs_view_axes_label,
		     axes_state->ax_view_linewidth,
		     0, /* positive direction only */
		     0, /* three colors (i.e. X-red, Y-green, Z-blue) */
		     0, /* no ticks */
		     0, /* tick len */
		     0, /* major tick len */
		     0, /* tick interval */
		     0, /* ticks per major */
		     NULL, /* tick color */
		     NULL, /* major tick color */
		     0 /* tick threshold */);
}
Exemplo n.º 24
0
HIDDEN int
avpp_val_compare(const char *val1, const char *val2, const struct bn_tol *diff_tol)
{
    /* We need to look for numbers to do tolerance based comparisons */
    int num_compare = 1;
    int color_compare = 1;
    int pnt_compare = 1;
    double dval1, dval2;
    int c1val1, c1val2, c1val3;
    int c2val1, c2val2, c2val3;
    float p1val1, p1val2, p1val3;
    float p2val1, p2val2, p2val3;
    char *endptr;
    /* Don't try a numerical comparison unless the strings differ -
     * numerical attempts when they are not needed can introduce
     * invalid changes */
    int retval = BU_STR_EQUAL(val1, val2);

    if (!retval) {
	/* First, check for individual numbers */
	errno = 0;
	dval1 = strtod(val1, &endptr);
	if (errno == EINVAL || *endptr != '\0') num_compare--;
	errno = 0;
	dval2 = strtod(val2, &endptr);
	if (errno == EINVAL || *endptr != '\0') num_compare--;
	if (num_compare == 1) {return NEAR_EQUAL(dval1, dval2, diff_tol->dist);}

	/* If we didn't find numbers, try for colors (3 integer numbers) */
	if (sscanf(val1, "%d %d %d", &c1val1, &c1val2, &c1val3) == 3) color_compare--;
	if (sscanf(val2, "%d %d %d", &c2val1, &c2val2, &c2val3) == 3) color_compare--;
	if (color_compare == 1) return retval;

	/* If we didn't find numbers, try for points (3 floating point numbers) */
	if (sscanf(val1, "%f %f %f", &p1val1, &p1val2, &p1val3) == 3) pnt_compare--;
	if (sscanf(val2, "%f %f %f", &p2val1, &p2val2, &p2val3) == 3) pnt_compare--;

	if (pnt_compare == 1) {
	    vect_t v1, v2;
	    VSET(v1, p1val1, p1val2, p1val3);
	    VSET(v2, p2val1, p2val2, p2val3);
	    return VNEAR_EQUAL(v1, v2, diff_tol->dist);
	}
    }
    return retval;
}
Exemplo n.º 25
0
void drift2(gsl_vector *mean_cand, gsl_vector *param1, double ddeltat)
{
  double m1,m2,k1,k2,k3,k4,k5,r1,r2;
  k1=VGET(param1,0);
  k2=VGET(param1,1);
  k3=VGET(param1,2);
  k4=VGET(param1,3);
  k5=VGET(param1,4);
  r1=VGET(mean_cand,0);
  r2=VGET(mean_cand,1);
    
  m1=ddeltat*(k1-k3*r1-k5*r1*r2);
  m2=ddeltat*(k2-k4*r2+20*k5*r1*r2);/*Change to 20*k5*r1*r2*/
    
  VSET(mean_cand, 0, m1+VGET(mean_cand, 0));
  VSET(mean_cand, 1, m2+VGET(mean_cand, 1));
}
Exemplo n.º 26
0
/*
 * Replica of STEP function:
 *   FUNCTION first_proj_axis()
 */
void
Axis2Placement3D::FirstProjAxis(double *proj,double *zaxis, double *refdir) {
    double z[3] = VINIT_ZERO;
    double v[3] = VINIT_ZERO;
    double TOL = 1e-9;

    if (zaxis == NULL)
	return;

    VMOVE(z,zaxis);
    VUNITIZE(z);
    if (refdir == NULL) {
	double xplus[3]=  {1.0,0.0,0.0};
	double xminus[3]=  {-1.0,0.0,0.0};
	if (!VNEAR_EQUAL(z, xplus, TOL) &&
	    !VNEAR_EQUAL(z, xminus, TOL))  {
	    VSET(v,1.0,0.0,0.0);
	} else {
	    VSET(v,0.0,1.0,0.0);
	}
    } else {
	double cross[3];
	double mag;

	VCROSS(cross, refdir, z);
	mag = MAGNITUDE(cross);
	if (NEAR_ZERO(mag,TOL)) {
	    return;
	} else {
	    VMOVE(v,refdir);
	    VUNITIZE(v);
	}

    }
    double x_vec[3];
    double aproj[3];
    double dot = VDOT(v,z);
    ScalarTimesVector(x_vec, dot, z);
    VectorDifference(aproj,v,x_vec);
    VSCALE(x_vec,z,dot);
    VSUB2(aproj,v, x_vec);
    VUNITIZE(aproj);
    VMOVE(proj,aproj);

    return;
}
Exemplo n.º 27
0
/**
 * Returns a vector of the vo-th parameter, built from
 * the list
 * @param kl
 * @param pl
 * @param el
 * @return 
 */
gsl_vector* KL_getPars(const ok_list* kl, const int vo) {
    gsl_vector* v = gsl_vector_alloc(kl->size);
    
    for (int i = 0; i < kl->size; i++)
        VSET(v, i, VGET(kl->kernels[i]->params, vo));
    
    return v;
}
Exemplo n.º 28
0
int
mat_build(fastf_t *mat1, fastf_t *mat2, fastf_t *regismat)
{

    vect_t	adelta, bdelta;		/* deltas for mod1 and mod2 */
    vect_t	delta;			/* difference bet. mod1 and mod2 deltas */
    fastf_t	scale;

    /* At this point it is important to check that the rotation part
     * of the matices is within a certain tolerance: ie. that the
     * two images were raytraced from the same angle.  No overlays will
     * be possible if they are not at the same rotation.
     */

    /* Now record the deltas: the translation part of the matrix. */
    VSET(adelta, mat1[MDX], mat1[MDY], mat1[MDZ]);
    VSET(bdelta, mat2[MDX], mat2[MDY], mat2[MDZ]);

    /* Take the difference between the deltas. Also scale the size
     * of the model (scale).  These will be used to register two
     * pixel files later on.
     */

    VSUB2(delta, adelta, bdelta);
    scale = mat1[15]/mat2[15];

    VPRINT("delta", delta);
    fprintf(stderr, "scale: %.6f\n", scale);

    /* If the first log corresponds to a UNIX-Plot file, following
     * applies.  Since UNIX-Plot files are in model coordinates, the
     * mod2view2 ("model2pix") is also the registration matrix.  In
     * this case, pl-fb needs to learn that the UNIX-Plot file's space
     * runs from -1 -> 1 in x and y.  This can be done by adding an
     * alternate space command in that program. Therefore the below
     * applies.
     * What if the first log corresponds to a hi-res pixel file to be
     * registered with a lo-res pixel file?  Then the above calculated
     * deltas are used.   This will be implemented later.
     */

    MAT_COPY( regismat, mat2);
    bn_mat_print("regismat", regismat);
    return(1);				/* OK */
}
void
plot_face(ON_3dPoint *pt1, ON_3dPoint *pt2, ON_3dPoint *pt3, int r, int g, int b, FILE *c_plot)
{
    point_t p1, p2, p3;

    VSET(p1, pt1->x, pt1->y, pt1->z);
    VSET(p2, pt2->x, pt2->y, pt2->z);
    VSET(p3, pt3->x, pt3->y, pt3->z);

    pl_color(c_plot, r, g, b);

    pdv_3move(c_plot, p1);
    pdv_3cont(c_plot, p2);
    pdv_3move(c_plot, p1);
    pdv_3cont(c_plot, p3);
    pdv_3move(c_plot, p2);
    pdv_3cont(c_plot, p3);
}
Exemplo n.º 30
0
/*
 *  Go poke the rgb values of a region, on the fly.
 *  This does not update the inmemory database,
 *  so any changes will vanish on next re-prep unless other measures
 *  are taken.
 */
int
sh_directchange_rgb(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const char *argv[])
{
    long int rtip_val;
    struct rt_i	*rtip;
    struct region	*regp;
    struct directory *dp;
    float		r, g, b;

    if ( argc != 6 )  {
	Tcl_AppendResult(interp, "Usage: sh_directchange_rgb $rtip comb r g b\n", NULL);
	return TCL_ERROR;
    }

    r = atoi(argv[3+0]) / 255.0;
    g = atoi(argv[3+1]) / 255.0;
    b = atoi(argv[3+2]) / 255.0;

    rtip_val = atol(argv[1]);
    rtip = (struct rt_i *)rtip_val;
    RT_CK_RTI(rtip);

    if ( rtip->needprep )  {
	Tcl_AppendResult(interp, "rt_prep() hasn't been called yet, error.\n", NULL);
	return TCL_ERROR;
    }

    if ( (dp = db_lookup( rtip->rti_dbip, argv[2], LOOKUP_NOISY)) == RT_DIR_NULL )  {
	Tcl_AppendResult(interp, argv[2], ": not found\n", NULL);
	return TCL_ERROR;
    }

    /* Find all region names which match /comb/ pattern */
    for ( BU_LIST_FOR( regp, region, &rtip->HeadRegion ) )  {
/*	if ( dp->d_flags & RT_DIR_REGION )  {	*/
	    /* name will occur at end of region string w/leading slash */
/*	} else {	*/
	    /* name will occur anywhere, bracketed by slashes */
/*	}	*/

	/* XXX quick hack */
	if ( strstr( regp->reg_name, argv[2] ) == NULL )  continue;

	/* Modify the region's color */
	bu_log("sh_directchange_rgb() changing %s\n", regp->reg_name);
	VSET( regp->reg_mater.ma_color, r, g, b );

	/* Update the shader */
	mlib_free(regp);
	if ( mlib_setup( &mfHead, regp, rtip ) != 1 )  {
	    Tcl_AppendResult(interp, regp->reg_name, ": mlib_setup() failure\n", NULL);
	}
    }

    return TCL_OK;
}