/////////////////////////////////////////////////////////////// // // pow4-ij.cpp // // - Define the equation of a quartic CP2 genus 3 cross-section of K3 // - change the DEFINE's to choose +/- xi range, values of n and k1,k2 // A. Hanson Oct 2005 // // 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 "pow4.h" // Parameters XIMAX, XISTEPS, XISCALE, THSTEPS /////////////////////////////////////////////////////////////// // (PART A) MATHEMATICAL NOTE /////////////////////////////////////////////////////////////// // *** <0> EDIT HERE (optional) #define POW4_00_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 #define XIsign (1) // false gives negative half, true gives positive half #define Nval (4.0) #define K1val (0.0) #define K2val (3.0) #define RED_VAL (0.4) #define GREEN_VAL (1.0) #define BLUE_VAL (0.4) /////////////////////////////////////////////////////////////// // (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 (embeding dimension) #define NUM_DIM 9 //////////////////////////////////////////////////// // 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,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)/Nval; X1 = rr*cos(angle)*cos(M_PI/Nval + (2*K1val*M_PI)/Nval) - rr*sin(angle)*sin(M_PI/Nval + (2*K1val*M_PI)/Nval); Y1 = rr*cos(angle)*sin(M_PI/Nval + (2*K1val*M_PI)/Nval) + rr*sin(angle)*cos(M_PI/Nval + (2*K1val*M_PI)/Nval); 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)/Nval; X2 = rr*cos(angle)*cos(M_PI/Nval + (2*K2val*M_PI)/Nval) - rr*sin(angle)*sin(M_PI/Nval + (2*K2val*M_PI)/Nval); Y2 = rr*cos(angle)*sin(M_PI/Nval + (2*K2val*M_PI)/Nval) + rr*sin(angle)*cos(M_PI/Nval + (2*K2val*M_PI)/Nval); X0=1.0; Y0 = 0.0; denom = (X0*X0 + Y0*Y0 + X1*X1 + Y1*Y1 + X2*X2 + Y2*Y2); DIM(0) = (X0*X0 + Y0*Y0)/denom; DIM(1) = (X1*X1 + Y1*Y1)/denom; DIM(2) = (X2*X2 + Y2*Y2)/denom; DIM(3) = rt2*(X0* X1 + Y0* Y1)/denom; DIM(4) = rt2*(X1* Y0 - X0* Y1)/denom; DIM(5) = rt2*(X1* X2 + Y1* Y2)/denom; DIM(6) = rt2*(X2* Y1 - X1* Y2)/denom; DIM(7) = rt2*(X0* X2 + Y0* Y2)/denom; DIM(8) = rt2*(X0* Y2 - X2* Y0)/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( "CP2 " ) ; eqdef->description = strdup( POW4_00_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] = RED_VAL ; out_color_array[1] = GREEN_VAL ; out_color_array[2] = BLUE_VAL ; }