HIDDEN int convert_all_cs(void) { int ret=0; struct coord_sys *cs; for (BU_LIST_FOR(cs, coord_sys, &coord_head.l)) { if (convert_cs(cs)) ret = 1; } return ret; }
HIDDEN int convert_pt( const point_t pt, struct coord_sys *cs, point_t out_pt ) { point_t tmp_pt; fastf_t c1, c2, c3, c4; if ( cs->rid ) { if ( convert_cs( cs ) ) return( 1 ); } switch ( cs->type ) { case CORD_CYL: c1 = pt[X] * cos( pt[Y] * bn_degtorad ); c2 = pt[X] * sin( pt[Y] * bn_degtorad ); VJOIN3( tmp_pt, cs->origin, c1, cs->v1, c2, cs->v2, pt[Z], cs->v3); VMOVE( out_pt, tmp_pt ); break; case CORD_RECT: VJOIN3( tmp_pt, cs->origin, pt[X], cs->v1, pt[Y], cs->v2, pt[Z], cs->v3 ); VMOVE( out_pt, tmp_pt ); break; case CORD_SPH: c4 = pt[X] * sin( pt[Y] * bn_degtorad ); c1 = c4 * cos( pt[Z] * bn_degtorad ); c2 = c4 * sin( pt[Z] * bn_degtorad ); c3 = pt[X] * cos( pt[Y] * bn_degtorad ); VJOIN3( tmp_pt, cs->origin, c1, cs->v1, c2, cs->v2, c3, cs->v3); VMOVE( out_pt, tmp_pt ); break; default: bu_exit(1, "Unrecognized coordinate system type (%c) for cid=%d!\n", cs->type, cs->cid ); } return( 0 ); }