Example #1
0
/*-------------------------------------------------------------------
    Procedure   :   Build XYZ Quaternion
    Input       :   float       X Rotation ( Degrees )
                :   float       Y Rotation ( Degrees )
                :   float       Z Rotation ( Degrees )
                :   QUAT    *   Destination Quaternion
    Output      :   Nothing
-------------------------------------------------------------------*/
void MakeQuat( float XRot, float YRot, float ZRot, QUAT * qxyz )
{
    QUAT    qx;
    QUAT    qy;
    QUAT    qz;
    QUAT    qxy;

    qx.w = (float) COSD( XRot * 0.5F );
    qx.x = (float) SIND( XRot * 0.5F );
    qx.y = 0.0F;
    qx.z = 0.0F;

    qy.w = (float) COSD( YRot * 0.5F );
    qy.x = 0.0F;
    qy.y = (float) SIND( YRot * 0.5F );
    qy.z = 0.0F;

    qz.w = (float) COSD( ZRot * 0.5F );
    qz.x = 0.0F;
    qz.y = 0.0F;
    qz.z = (float) SIND( ZRot * 0.5F );

    QuatMultiplyX_Y( &qx, &qy, &qxy );
    QuatMultiplyXY_Z( &qxy, &qz, qxyz );
}
Example #2
0
void MakeQuat( float XRot, float YRot, float ZRot , QUAT * qxyz )
{
    float  cosZRot, sinZRot, cosYRot, sinYRot, cosXRot, sinXRot;
    float  half_XRot, half_YRot, half_ZRot;
    /* put angles into radians and divide by two, since all angles in formula
     *  are (angle/2)
     */
    
    half_ZRot = ZRot * 0.5F;
    half_YRot = YRot * 0.5F;
    half_XRot = XRot * 0.5F;
    
    cosZRot = (float) COSD(half_ZRot);
    sinZRot = (float) SIND(half_ZRot);
    
    cosYRot = (float) COSD(half_YRot);
    sinYRot = (float) SIND(half_YRot);
    
    cosXRot = (float) COSD(half_XRot);
    sinXRot = (float) SIND(half_XRot);
    
    
    qxyz->x = sinXRot * cosYRot * cosZRot - cosXRot * sinYRot * sinZRot;
    qxyz->y = cosXRot * sinYRot * cosZRot + sinXRot * cosYRot * sinZRot;
    qxyz->z = cosXRot * cosYRot * sinZRot - sinXRot * sinYRot * cosZRot;
    
    qxyz->w = cosXRot * cosYRot * cosZRot + sinXRot * sinYRot * sinZRot;

}   /* q_from_euler */
Example #3
0
	void run()
	{

		int iline = 0;
		FOR_ALL_OBJECTS_IN_METADATA_TABLE(MDu)
		{


			// Read input data
	        DOUBLE rot1,  tilt1,  psi1;
	        DOUBLE rot2,  tilt2,  psi2;
	        DOUBLE rot2p, tilt2p, psi2p;
	        DOUBLE best_tilt, best_alpha, best_beta;
	        DOUBLE distp;

	        MDu.getValue(EMDL_ORIENT_ROT, rot1);
	        MDt.getValue(EMDL_ORIENT_ROT, rot2, iline);
	        MDu.getValue(EMDL_ORIENT_TILT, tilt1);
	        MDt.getValue(EMDL_ORIENT_TILT, tilt2, iline);
	        MDu.getValue(EMDL_ORIENT_PSI, psi1);
	        MDt.getValue(EMDL_ORIENT_PSI, psi2, iline);
	        iline++;

	        // Bring both angles to a normalized set
	        rot1 = realWRAP(rot1, -180, 180);
	        tilt1 = realWRAP(tilt1, -180, 180);
	        psi1 = realWRAP(psi1, -180, 180);
	        rot2 = realWRAP(rot2, -180, 180);
	        tilt2 = realWRAP(tilt2, -180, 180);
	        psi2 = realWRAP(psi2, -180, 180);

	        // Apply rotations to find the minimum distance angles
	        rot2p = rot2;
	        tilt2p = tilt2;
	        psi2p = psi2;
	        distp = check_symmetries(rot1, tilt1, psi1, rot2p, tilt2p, psi2p);

	        // Calculate distance to user-defined point
			DOUBLE xp, yp, x, y;
			Matrix1D<DOUBLE> aux2(4);
			xp = dist_from_tilt * COSD(dist_from_alpha);
			yp = dist_from_tilt * SIND(dist_from_alpha);
			x = tilt2p * COSD(rot2p);
			y = tilt2p * SIND(rot2p);
			aux2(3) = sqrt((xp-x)*(xp-x) + (yp-y)*(yp-y));
			aux2(0) = tilt2p;
			aux2(1) = rot2p;
			aux2(2) = psi2p;
			add_to_postscript(tilt2p, rot2p, psi2p);

	    }

		// Close the EPS file to write it to disk
    	fh_eps << "showpage\n";
        fh_eps.close();

	}
Example #4
0
	void add_to_postscript(DOUBLE tilt_angle, DOUBLE alpha, DOUBLE beta)
	{

		DOUBLE rr, th, x, y, r, g, b;

		rr = (tilt_angle / plot_max_tilt)* 250;
		x = 300. + rr * COSD(alpha);
		y = 400. + rr * SIND(alpha);
		value_to_redblue_scale(ABS(90.-beta), 0., 90., r, g, b);
		fh_eps << x << " " << y << " " << plot_spot_radius << " 0 360 arc closepath "<<r<<" "<<g<<" "<<b<<" setrgbcolor fill stroke\n";
	}
void GLAPIENTRY
gluPartialDisk(GLUquadricObj * qobj, GLdouble innerRadius,
	       GLdouble outerRadius, GLint slices, GLint loops,
	       GLdouble startAngle, GLdouble sweepAngle)
{
   if (qobj->Normals != GLU_NONE) {
      if (qobj->Orientation == GLU_OUTSIDE) {
	 glNormal3f(0.0, 0.0, +1.0);
      }
      else {
	 glNormal3f(0.0, 0.0, -1.0);
      }
   }

   if (qobj->DrawStyle == GLU_POINT) {
      GLint loop, slice;
      GLdouble radius, delta_radius;
      GLdouble angle, delta_angle;
      delta_radius = (outerRadius - innerRadius) / (loops - 1);
      delta_angle = DEG_TO_RAD((sweepAngle) / (slices - 1));
      glBegin(GL_POINTS);
      radius = innerRadius;
      for (loop = 0; loop < loops; loop++) {
	 angle = DEG_TO_RAD(startAngle);
	 for (slice = 0; slice < slices; slice++) {
	    glVertex2d(radius * sin(angle), radius * cos(angle));
	    angle += delta_angle;
	 }
	 radius += delta_radius;
      }
      glEnd();
   }
   else if (qobj->DrawStyle == GLU_LINE) {
      GLint loop, slice;
      GLdouble radius, delta_radius;
      GLdouble angle, delta_angle;
      delta_radius = (outerRadius - innerRadius) / loops;
      delta_angle = DEG_TO_RAD(sweepAngle / slices);
      /* draw rings */
      radius = innerRadius;
      for (loop = 0; loop < loops; loop++) {
	 angle = DEG_TO_RAD(startAngle);
	 glBegin(GL_LINE_STRIP);
	 for (slice = 0; slice <= slices; slice++) {
	    glVertex2d(radius * sin(angle), radius * cos(angle));
	    angle += delta_angle;
	 }
	 glEnd();
	 radius += delta_radius;
      }
      /* draw spokes */
      angle = DEG_TO_RAD(startAngle);
      for (slice = 0; slice <= slices; slice++) {
	 radius = innerRadius;
	 glBegin(GL_LINE_STRIP);
	 for (loop = 0; loop < loops; loop++) {
	    glVertex2d(radius * sin(angle), radius * cos(angle));
	    radius += delta_radius;
	 }
	 glEnd();
	 angle += delta_angle;
      }
   }
   else if (qobj->DrawStyle == GLU_SILHOUETTE) {
      GLint slice;
      GLdouble angle, delta_angle;
      delta_angle = DEG_TO_RAD(sweepAngle / slices);
      /* draw outer ring */
      glBegin(GL_LINE_STRIP);
      angle = DEG_TO_RAD(startAngle);
      for (slice = 0; slice <= slices; slice++) {
	 glVertex2d(outerRadius * sin(angle), outerRadius * cos(angle));
	 angle += delta_angle;
      }
      glEnd();
      /* draw inner ring */
      if (innerRadius > 0.0) {
	 glBegin(GL_LINE_STRIP);
	 angle = DEG_TO_RAD(startAngle);
	 for (slice = 0; slice < slices; slice++) {
	    glVertex2d(innerRadius * sin(angle), innerRadius * cos(angle));
	    angle += delta_angle;
	 }
	 glEnd();
      }
      /* draw spokes */
      if (sweepAngle < 360.0) {
	 GLdouble stopAngle = startAngle + sweepAngle;
	 glBegin(GL_LINES);
	 glVertex2d(innerRadius * SIND(startAngle),
		    innerRadius * COSD(startAngle));
	 glVertex2d(outerRadius * SIND(startAngle),
		    outerRadius * COSD(startAngle));
	 glVertex2d(innerRadius * SIND(stopAngle),
		    innerRadius * COSD(stopAngle));
	 glVertex2d(outerRadius * SIND(stopAngle),
		    outerRadius * COSD(stopAngle));
	 glEnd();
      }
   }
   else if (qobj->DrawStyle == GLU_FILL) {
      GLint loop, slice;
      GLdouble radius, delta_radius;
      GLdouble angle, delta_angle;
      delta_radius = (outerRadius - innerRadius) / loops;
      delta_angle = DEG_TO_RAD(sweepAngle / slices);
      radius = innerRadius;
      for (loop = 0; loop < loops; loop++) {
	 glBegin(GL_QUAD_STRIP);
	 angle = DEG_TO_RAD(startAngle);
	 for (slice = 0; slice <= slices; slice++) {
	    if (qobj->Orientation == GLU_OUTSIDE) {
	       glVertex2d((radius + delta_radius) * sin(angle),
			  (radius + delta_radius) * cos(angle));
	       glVertex2d(radius * sin(angle), radius * cos(angle));
	    }
	    else {
	       glVertex2d(radius * sin(angle), radius * cos(angle));
	       glVertex2d((radius + delta_radius) * sin(angle),
			  (radius + delta_radius) * cos(angle));
	    }
	    angle += delta_angle;
	 }
	 glEnd();
	 radius += delta_radius;
      }
   }
}
Example #6
0
// Constructor -------------------------------------------------------------
Steerable::Steerable(double sigma, MultidimArray<double> &Vtomograph,
    double deltaAng, const std::string &filterType, const MissingWedge *_MW) 
{
    MW=_MW;
    buildBasis(Vtomograph,sigma);
 
    // Choose a,b,c parameters as a function of the filterType
    double a; 
    double b; 
    double c;
    if (filterType == "wall") {
        // for wall structures
        a = -(1.0/4.0);
        b = 5.0/4.0;
        c = 5.0/2.0;
    }
    else{      
        // for filament structures
        a = 1.0;
        b = -(5.0/3.0);
        c = 10.0/3.0;
    }

    // Filter along tilt=0 and 180 => u=(1,0,0)
    double u0=1;
    double u1=0;
    double u2=0;                
    FOR_ALL_ELEMENTS_IN_ARRAY3D(Vtomograph){
        Vtomograph(k,i,j) = basis[0](k,i,j) * (a+b*u0*u0) +
                            basis[1](k,i,j) * (a+b*u1*u1) +
                            basis[2](k,i,j) * (a+b*u2*u2) +
                         c*(basis[3](k,i,j) * u0*u1 + 
                            basis[4](k,i,j) * u0*u2 + 
                            basis[5](k,i,j) * u1*u2);
    }

    // Filter the rest of directions and keep the maximum
    double Ntilt = round(180.0/deltaAng);  
    for (int i=1;i<Ntilt;i++){
        double tilt = deltaAng*i;
        double deltaRoti = deltaAng/SIND(tilt);
        double NrotP = round(360.0/deltaRoti);        
        for (int j=0;j<NrotP;j++){
            double rot = j*deltaRoti;
            double u0 = SIND(rot)*COSD(tilt);
            double u1 = SIND(rot)*SIND(tilt);
            double u2 = COSD(rot);
            FOR_ALL_ELEMENTS_IN_ARRAY3D(Vtomograph)
            {
                double filterval =
                    basis[0](k,i,j) * (a+b*u0*u0) +
                    basis[1](k,i,j) * (a+b*u1*u1) +
                    basis[2](k,i,j) * (a+b*u2*u2) +
                 c*(basis[3](k,i,j) * u0*u1 + 
                    basis[4](k,i,j) * u0*u2 + 
                    basis[5](k,i,j) * u1*u2);

                if(filterval>Vtomograph(k,i,j))
                    Vtomograph(k,i,j) = filterval;
            }
        }
    }
}