/////////////////////////////////////////////////////////////// // // K3z0.template // // 18 z=0 triangle subspace patches of K3 // // notation: ij=phase label, 18 cases +/- = p/m, i=0:2 // a,b,c,d,e,f,g,h,i,j... = skeleton surface // patches of 4-polytope for one phase. // // - Define the equation of a quartic Calabi-Yau K3 // A. Hanson Oct 2005 // // ND plugin: original version by Philip Fu (cwfu@acm.org) // // 3/9/2003 1:18PM // // All rights reserved // // NOTE: // - To add an equation, make modifications marked by "EDIT HERE" // /////////////////////////////////////////////////////////////// #include #include #include #include #include "ndeqdef.h" #include "eqcommon.h" #include "K3z.h" // Parameters XIMAX, XISTEPS, XISCALE, THSTEPS /////////////////////////////////////////////////////////////// // (PART A) MATHEMATICAL NOTE /////////////////////////////////////////////////////////////// // *** <0> EDIT HERE (optional) #define K3_000_DESC "\ \n\ \n\ \n\ - 2 parameters: theta1 and theta2 range from 0 to 2Pi\n\ - 1 complex cubic equation:\n\ - It is a 2D manifold embedding in 4D space\n" // POWERS of general equation can be substituted HERE // x = define XIsign (0) // 0=false gives negative half, 1=true gives positive half // y = define K1val (i) // z = define K2val (j) #define Nval (4.0) #define XIsign (1.0) #define K1val (0.0) #define K2val (3.0) /////////////////////////////////////////////////////////////// // (PART B) INDIVIDUAL FUNCTIONS FOR EACH DIMENSION /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////// // Number of Parameters and Dimensions //////////////////////////////////////////////////// // *** <1> EDIT HERE // number of parameters #define NUM_PARA 2 // number of dimensions (embedding dimension) #define NUM_DIM 16 //////////////////////////////////////////////////// // You may give name to the parameters by #define //////////////////////////////////////////////////// // *** <2> EDIT HERE (optional) #define th (in_para_array[0]) #define xi (in_para_array[1]) #define DIM(i) (out_value_array[(i)]) //////////////////////////////////////////////////// // Define the actual equations defined here //////////////////////////////////////////////////// // NOte: // - NUM_PARA - number of elements in in_para_array // NUM_DIM - number of elements in out_value_array // - Make sure the array index isn't out of range, otherwise, may crash! // *** <3> EDIT HERE PLUGIN_API void computeEquation( const double in_para_array [_MAX_PARAM] , double out_value_array [_MAX_DIM] ) { double xx,yy,rr,X0,Y0,X1,Y1,X2,Y2,X3,Y3,denom,expxi,rt2,angle; rt2 = sqrt(2.0); expxi = XISCALE*sinh(xi); xx = cosh(expxi)*cos(th); yy = sinh(expxi)*sin(th); rr = pow(xx*xx+yy*yy,1.0/Nval); angle = (2.0*atan2(yy,xx) + M_PI + 2*K1val*M_PI)/Nval; X1 = rr*cos(angle); Y1 = rr*sin(angle); xx = cosh(expxi)*sin(th); yy = - sinh(expxi)*cos(th); rr = pow(xx*xx+yy*yy,1.0/Nval); angle = (2.0*atan2(yy,xx) + M_PI + 2*K2val*M_PI)/Nval; X2 = rr*cos(angle); Y2 = rr*sin(angle); X3= 1.0; Y3 = 0.0; X0= 0.0; Y0 = 0.0; denom = (X0*X0 + Y0*Y0 + X1*X1 + Y1*Y1 + X2*X2 + Y2*Y2 +X3*X3 + Y3*Y3); DIM(0) = (X0*X0 + Y0*Y0)/denom; DIM(1) = (X1*X1 + Y1*Y1)/denom; DIM(2) = (X2*X2 + Y2*Y2)/denom; DIM(3) = (X3*X3 + Y3*Y3)/denom; DIM(4) = rt2*(X0* X1 + Y0* Y1)/denom; DIM(5) = rt2*(X1* Y0 - X0* Y1)/denom; DIM(6) = rt2*(X0* X2 + Y0* Y2)/denom; DIM(7) = rt2*(X0* Y2 - X2* Y0)/denom; DIM(8) = rt2*(X0* X3 + Y0* Y3)/denom; DIM(9) = rt2*(X0* Y3 - X3* Y0)/denom; DIM(10) = rt2*(X2* X3 + Y2* Y3)/denom; DIM(11) = - rt2*(X3* Y2 - X2* Y3)/denom; /* This minus sign appears necessary */ DIM(12) = rt2*(X3* X1 + Y3* Y1)/denom; DIM(13) = rt2*(X1* Y3 - X3* Y1)/denom; DIM(14) = rt2*(X1* X2 + Y1* Y2)/denom; DIM(15) = rt2*(X2* Y1 - X1* Y2)/denom; } /////////////////////////////////////////////////////////////// // (PART C) DEFINE THE ND EQUATION /////////////////////////////////////////////////////////////// // return false if this equation is not defined. PLUGIN_API bool defineEquation( ND_Equation_Def *eqdef ) { /////////////////////////////////////////////////////// // (1) Comment the first line below to when the code is ready /////////////////////////////////////////////////////// // *** <4> EDIT HERE //#define EQUATION_NOT_DEFINED #ifdef EQUATION_NOT_DEFINED return false; #else /////////////////////////////////////////////////////// // (2) Define the name and description /////////////////////////////////////////////////////// // *** <5> EDIT HERE eqdef->name = strdup( "CP3 Kummer - 00" ) ; eqdef->description = strdup( K3_000_DESC ) ; /////////////////////////////////////////////////////// // (3) Number of Parameters (M) and // Number of Dimension (N) /////////////////////////////////////////////////////// eqdef->numPara = NUM_PARA ; eqdef->numDim = NUM_DIM ; /////////////////////////////////////////////////////// // (4) Parameters Range and Max. Subdivision /////////////////////////////////////////////////////// // - Make sure the array index isn't out of range, otherwise, may crash! // - from 0 to NUM_PARA-1 // *** <6> EDIT HERE th = theta is first, then xi eqdef->range_min[0] = 0.0 ; eqdef->range_min[1] = XIsign ? 0.0: - XIMAX; eqdef->range_max[0] = M_PI/2 ; // theta 0 to pi/2 eqdef->range_max[1] = XIsign ? XIMAX: 0.0 ; // -ximax to ximax eqdef->max_subdivision[0] = THSTEPS ; eqdef->max_subdivision[1] = XISTEPS ; return true; #endif } /////////////////////////////////////////////////////////////// // (PART D) FREE THE ALLOCATED MEMORY (DO NOT EDIT) /////////////////////////////////////////////////////////////// PLUGIN_API void freeEquation( const ND_Equation_Def *eqdef ) { if ( eqdef->description ) free ( eqdef->description ) ; if ( eqdef->name ) free ( eqdef->name ) ; } //////////////////////////////////////////////////// // (PART E) Optional function for setting the color function //////////////////////////////////////////////////// // Note: // - NUM_PARA - number of elements in in_para_array // - there are three colors in the out_color_array (output: ranged [0,1]) // - Make sure the array index isn't out of range, otherwise, may crash! // *** <7> MAY EDIT HERE PLUGIN_API void colorFunction( const double in_para_array [_MAX_PARAM] , double out_color_array [3] ) { out_color_array[0] = 1.0 ; out_color_array[1] = 1.0 ; out_color_array[2] = (K1val+K2val)*(1-XIsign*0.3)/4.0; }