Index: sansmodels/src/sans/models/c_extensions/elliptical_cylinder.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/elliptical_cylinder.c	(revision ae3ce4eaa593202ebf49122e196897c0d45a25b6)
+++ sansmodels/src/sans/models/c_extensions/elliptical_cylinder.c	(revision 3fe701ac3c29b7d1a7fac25287edf2801095936d)
@@ -18,5 +18,5 @@
 double elliptical_cylinder_analytical_1D(EllipticalCylinderParameters *pars, double q) {
 	double dp[6];
-	
+
 	// Fill paramater array
 	dp[0] = pars->scale;
@@ -26,20 +26,20 @@
 	dp[4] = pars->contrast;
 	dp[5] = pars->background;
-	
+
 	// Call library function to evaluate model
-	return EllipCyl20(dp, q);	
+	return EllipCyl20(dp, q);
 }
 
-double elliptical_cylinder_kernel(EllipticalCylinderParameters *pars, double q, double alpha, double psi) {
+double elliptical_cylinder_kernel(EllipticalCylinderParameters *pars, double q, double alpha, double psi, double nu) {
 	double qr;
 	double qL;
 	double r_major;
 	double kernel;
-	
+
 	r_major = pars->r_ratio * pars->r_minor;
 
-	qr = q*sin(alpha)*sqrt( r_major*r_major*sin(psi)*sin(psi) + pars->r_minor*pars->r_minor*cos(psi)*cos(psi) );
+	qr = q*sin(alpha)*sqrt( r_major*r_major*sin(nu)*sin(nu) + pars->r_minor*pars->r_minor*cos(nu)*cos(nu) );
 	qL = q*pars->length*cos(alpha)/2.0;
-	
+
 	kernel = 2.0*NR_BessJ1(qr)/qr * sin(qL)/qL;
 	return kernel*kernel;
@@ -56,5 +56,5 @@
 	q = sqrt(qx*qx+qy*qy);
     return elliptical_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-} 
+}
 
 /**
@@ -62,10 +62,11 @@
  * @param pars: parameters of the cylinder
  * @param q: q-value
- * @param phi: angle phi
+ * @param theta: angle theta = angle wrt z axis
+ * @param phi: angle phi = angle around y axis (starting from the x+-direction as phi = 0)
  * @return: function value
  */
 double elliptical_cylinder_analytical_2D(EllipticalCylinderParameters *pars, double q, double phi) {
     return elliptical_cylinder_analytical_2D_scaled(pars, q, cos(phi), sin(phi));
-} 
+}
 
 /**
@@ -79,20 +80,22 @@
 double elliptical_cylinder_analytical_2D_scaled(EllipticalCylinderParameters *pars, double q, double q_x, double q_y) {
 	double cyl_x, cyl_y, cyl_z;
+	double ell_x, ell_y;
 	double q_z;
 	double alpha, vol, cos_val;
+	double nu, cos_nu;
 	double answer;
-        
-    // Cylinder orientation
+
+    //Cylinder orientation
     cyl_x = sin(pars->cyl_theta) * cos(pars->cyl_phi);
     cyl_y = sin(pars->cyl_theta) * sin(pars->cyl_phi);
     cyl_z = cos(pars->cyl_theta);
-     
+
     // q vector
     q_z = 0;
-        
+
     // Compute the angle btw vector q and the
     // axis of the cylinder
     cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z;
-    
+
     // The following test should always pass
     if (fabs(cos_val)>1.0) {
@@ -100,29 +103,50 @@
      	return 0;
     }
-    
+
     // Note: cos(alpha) = 0 and 1 will get an
     // undefined value from CylKernel
 	alpha = acos( cos_val );
-	
-	answer = elliptical_cylinder_kernel(pars, q, alpha, pars->cyl_psi);
-	
+
+    //ellipse orientation:
+	// the elliptical corss section was transformed and projected
+	// into the detector plane already through sin(alpha)and furthermore psi remains as same
+	// on the detector plane.
+	// So, all we need is to calculate the angle (nu) of the minor axis of the ellipse wrt
+	// the wave vector q.
+
+	//x- y- component on the detector plane.
+    ell_x =  cos(pars->cyl_psi);
+    ell_y =  sin(pars->cyl_psi);
+
+    // calculate the axis of the ellipse wrt q-coord.
+    cos_nu = ell_x*q_x + ell_y*q_y;
+    nu = acos(cos_nu);
+
+    // The following test should always pass
+    if (fabs(cos_nu)>1.0) {
+    	printf("cyl_ana_2D: Unexpected error: cos(nu)>1\n");
+     	return 0;
+    }
+
+	answer = elliptical_cylinder_kernel(pars, q, alpha, pars->cyl_psi,nu);
+
 	// Multiply by contrast^2
 	answer *= pars->contrast*pars->contrast;
-	
+
 	//normalize by cylinder volume
 	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
     vol = acos(-1.0) * pars->r_minor * pars->r_minor * pars->r_ratio * pars->length;
 	answer *= vol;
-	
+
 	//convert to [cm-1]
 	answer *= 1.0e8;
-	
+
 	//Scale
 	answer *= pars->scale;
-	
+
 	// add in the background
 	answer += pars->background;
-	
+
 	return answer;
 }
-    
+
