Index: sansmodels/src/c_extensions/fcc.c
===================================================================
--- sansmodels/src/c_extensions/fcc.c	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ sansmodels/src/c_extensions/fcc.c	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
@@ -0,0 +1,142 @@
+/*
+ * Scattering model for a SC_ParaCrystal
+ */
+#include "fcc.h"
+#include "libSphere.h"
+#include <math.h>
+#include <stdio.h>
+
+/**
+ * Function to evaluate 1D scattering function
+ * @param pars: parameters of the FCC_ParaCrystal
+ * @param q: q-value
+ * @return: function value
+ */
+double fcc_analytical_1D(FCParameters *pars, double q) {
+	double dp[7];
+	double result;
+
+	dp[0] = pars->scale;
+	dp[1] = pars->dnn;
+	dp[2] = pars->d_factor;
+	dp[3] = pars->radius;
+	dp[4] = pars->sldSph;
+	dp[5] = pars->sldSolv;
+	dp[6] = pars->background;
+
+	result = FCC_ParaCrystal(dp, q);
+	// This FIXES a singualrity the kernel in libigor.
+	if ( result == INFINITY || result == NAN){
+		result = pars->background;
+	}
+	return result;
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the FCC_ParaCrystal
+ * @param q: q-value
+ * @return: function value
+ */
+double fc_analytical_2DXY(FCParameters *pars, double qx, double qy){
+	double q;
+	q = sqrt(qx*qx+qy*qy);
+	return fc_analytical_2D_scaled(pars, q, qx/q, qy/q);
+}
+
+double fc_analytical_2D(FCParameters *pars, double q, double phi) {
+	return fc_analytical_2D_scaled(pars, q, cos(phi), sin(phi));
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the FCCCrystalModel
+ * @param q: q-value
+ * @param q_x: q_x / q
+ * @param q_y: q_y / q
+ * @return: function value
+ */
+double fc_analytical_2D_scaled(FCParameters *pars, double q, double q_x, double q_y) {
+	double b3_x, b3_y, b3_z, b1_x, b1_y;
+	double q_z;
+	double alpha, cos_val_b3, cos_val_b2, cos_val_b1;
+	double a1_dot_q, a2_dot_q,a3_dot_q;
+	double answer;
+	double Pi = 4.0*atan(1.0);
+	double aa, Da, qDa_2, latticeScale, Zq, Fkq, Fkq_2;
+
+	double dp[5];
+  //convert angle degree to radian
+  double theta = pars->theta * Pi/180.0;
+  double phi = pars->phi * Pi/180.0;
+  double psi = pars->psi * Pi/180.0;
+	dp[0] = 1.0;
+	dp[1] = pars->radius;
+	dp[2] = pars->sldSph;
+	dp[3] = pars->sldSolv;
+	dp[4] = 0.0;
+
+	aa = pars->dnn;
+	Da = pars->d_factor*aa;
+	qDa_2 = pow(q*Da,2.0);
+	//contrast = pars->sldSph - pars->sldSolv;
+
+	latticeScale = 4.0*(4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa*sqrt(2.0),3.0);
+	// q vector
+	q_z = 0.0; // for SANS; assuming qz is negligible
+	/// Angles here are respect to detector coordinate
+	///  instead of against q coordinate in PRB 36(46), 3(6), 1754(3854)
+    // b3 axis orientation
+    b3_x = sin(theta) * cos(phi);//negative sign here???
+    b3_y = sin(theta) * sin(phi);
+    b3_z = cos(theta);
+    cos_val_b3 =  b3_x*q_x + b3_y*q_y + b3_z*q_z;
+    alpha = acos(cos_val_b3);
+    // b1 axis orientation
+    b1_x = sin(psi);
+    b1_y = cos(psi);
+	cos_val_b1 = (b1_x*q_x + b1_y*q_y);
+    // b2 axis orientation
+	cos_val_b2 = sin(acos(cos_val_b1));
+	// alpha correction
+	cos_val_b2 *= sin(alpha);
+	cos_val_b1 *= sin(alpha);
+
+    // Compute the angle btw vector q and the a3 axis
+    a3_dot_q = 0.5*aa*q*(cos_val_b2+cos_val_b1);
+
+    // a1 axis
+    a1_dot_q = 0.5*aa*q*(cos_val_b2+cos_val_b3);
+
+    // a2 axis
+    a2_dot_q = 0.5*aa*q*(cos_val_b3+cos_val_b1);
+
+    // The following test should always pass
+    if (fabs(cos_val_b3)>1.0) {
+    	printf("fcc_ana_2D: Unexpected error: cos(alpha)>1\n");
+     	return 0;
+    }
+    // Get Fkq and Fkq_2
+    Fkq = exp(-0.5*pow(Da/aa,2.0)*(a1_dot_q*a1_dot_q+a2_dot_q*a2_dot_q+a3_dot_q*a3_dot_q));
+    Fkq_2 = Fkq*Fkq;
+    // Call Zq=Z1*Z2*Z3
+    Zq = (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a1_dot_q)+Fkq_2);
+    Zq = Zq * (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a2_dot_q)+Fkq_2);
+    Zq = Zq * (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a3_dot_q)+Fkq_2);
+
+	// Use SphereForm directly from libigor
+	answer = SphereForm(dp,q)*Zq;
+
+	//consider scales
+	answer *= latticeScale * pars->scale;
+
+	// This FIXES a singualrity the kernel in libigor.
+	if ( answer == INFINITY || answer == NAN){
+		answer = 0.0;
+	}
+
+	// add background
+	answer += pars->background;
+
+	return answer;
+}
