Пример #1
0
 /*
  * Transforms a spherical vector from 'spb' to 'spe' into an inverse Euler
  * transformation. Returns true if the transformation was successful.
  */
static bool
spherevector_to_euler_inv(SEuler *se, const SPoint *spb, const SPoint *spe)
{
	if (spoint_eq(spb, spe))
	{
		return false;
	}
	else
	{
		Vector3D	vbeg, vend, vtmp;
		SPoint		spt[2];
		SEuler		set;

		spoint_vector3d(&vbeg, spb);
		spoint_vector3d(&vend, spe);
		vector3d_cross(&vtmp, &vbeg, &vend);
		vector3d_spoint(&spt[0], &vtmp);
		set.phi = -spt[0].lng - PIH;
		set.theta = spt[0].lat - PIH;
		set.psi = 0.0;
		seuler_set_zxz(&set);
		euler_spoint_trans(&spt[1], spb, &set);
		set.psi = -spt[1].lng;
		memcpy((void *) se, (void *) &set, sizeof(SEuler));
	}

	return true;
}
Пример #2
0
 SPoint  * euler_spoint_trans ( SPoint * out , const SPoint  * in , const SEuler * se )
 {
   Vector3D v,o ;
   spoint_vector3d ( &v , in );
   euler_vector_trans ( &o , &v , se );
   vector3d_spoint ( out , &o );
   return out;
 }
Пример #3
0
  /*!
    \brief Checks crossing of line segments
    \param poly pointer to polygon
    \return true if crossing
  */
  static bool spherepoly_check ( const SPOLY * poly )
  {

    int32 i, k ;
    SLine sli, slk;
    Vector3D v ;
    SPoint  p;
    SEuler se;
    int8  pos;

    spherepoly_center ( &v , poly );
    // If 0-vector
    if ( FPzero(v.x) && FPzero(v.y) && FPzero(v.z) ){
      return FALSE;
    }
    
    for ( i=0; i<poly->npts; i++ ){
      spoly_segment   ( &sli , poly , i );
      for ( k=(i+1); k<poly->npts; k++ ){
        spoly_segment ( &slk , poly , k );
        pos = sline_sline_pos( &sli, &slk );
        if ( ! ( pos == PGS_LINE_CONNECT || pos == PGS_LINE_AVOID ) ) {
          return FALSE;
        }
      }
    }
    
    vector3d_spoint ( &p , &v );

    se.phi_a   = EULER_AXIS_Z  ;
    se.theta_a = EULER_AXIS_X  ;
    se.psi_a   = EULER_AXIS_Z  ;
    se.phi     = -PIH - p.lng  ;
    se.theta   = p.lat - PIH   ;
    se.psi     = 0.0           ;

    for ( i=0; i<poly->npts; i++ ){
      euler_spoint_trans ( &p , &poly->p[i], &se );
      // less _and_ equal are important !!
      // Do not change it!
      if ( FPle(p.lat,0.0) ) {
        return FALSE;
      }
    }
    return TRUE ;
  }