コード例 #1
0
ファイル: frag.c プロジェクト: substack/shader-emulation
void main() {
    const vec4 bg = vec4(0.5,0.5,0.5,1.0);
    
    // use the secant method on this interval
    const float d = length(C);
    
    // These are pretty well fine-tuned for the torus, but they work well enough
    // for the sphere too. If I had more time I could probably get rid of the
    // discontinuities in the transition.
    float t = pmin(
        secant_method(d - 1.2, d - 1.19, 1e-13),
        secant_method(d + 1.1, d + 1.0, 1e-13)
    );
    if (t < 0.0) {
        gl_FragColor = bg;
    }
    else {
        vec3 P = C + t * D; // point of intersection
        vec3 N = surfaceN(P, t, 0.01);
        vec3 L = normalize(vec3(3.0, 4.0, 5.0));
        float c = clamp(dot(N,L),0.0,1.0);
        //gl_FragColor = vec4(clamp(N,0.0,1.0),1.0);
        gl_FragColor = vec4(c,c,c,1.0);
    }
}
コード例 #2
0
int main()
{
   secant_method(0, 1);
   secant_method(3, 4);
   secant_method(6, 7);
   return 0;
}
コード例 #3
0
ファイル: CTest.c プロジェクト: RohanJ/PersonalTesting
int main(int argc, char *argv[])
{
	if(argc==1) 
    {
        printf("You must enter function\n");
        exit(1);     
    }
    char *fn_name;
    fn_name=argv[1];
    if(strcmp(fn_name,"function1")==0) function1(); //basic pointer aritmetic
    else if(strcmp(fn_name,"iscale")==0) iscale(--argc, ++argv); //generate E.T tables for N-notes to the octave (N<=24) ***NOTICE --argc and ++argv
    else if(strcmp(fn_name,"expdecay")==0) expdecay(--argc, ++argv); //generate exponential attack or decay breakpoint data
    else if(strcmp(fn_name,"sinetext")==0) sinetext(--argc, ++argv); //generate sinusoidal curve for use with GNUplot --> showcases use of enum
    else if(strcmp(fn_name,"byte_order")==0) { if(byte_order()==0) printf("System is big-endian\n"); else printf("System is little-endian\n"); } //tells endian type of system
    else if(strcmp(fn_name,"sf2float")==0) sf2float(--argc, ++argv); //convert soundfile to float format
    else if(strcmp(fn_name,"sig_gen")==0) sig_gen(--argc, ++argv); //generate oscillation signal (sine, triangle, square, sawtooth up, sawtooth down)
	else if(strcmp(fn_name,"osc_gen")==0) osc_gen(--argc, ++argv); //Oscillator Bank (Array of oscillators) for additive sythesis for the natural specturm of sound (classic square, trianlgle, saw_up, saw_down)
	else if(strcmp(fn_name,"summation_function")==0) summation_function(--argc, ++argv); // summation for a^n (CS473 Quiz3)
	else if(strcmp(fn_name,"secant_method")==0) secant_method(--argc, ++argv); // secant method implementation for CS357 Quiz3
	else if(strcmp(fn_name,"oddSumTest")==0) oddSumTest(--argc, ++argv); // oddSum program for Rishi
	else if(strcmp(fn_name,"pointerTest")==0) pointerTest();//pointer test for CS241
	else if(strcmp(fn_name,"aQRec")==0) aQRec(); //tests for audioQueueRecorder
    else
    {
        printf("Function not found\n");
        exit(1);
    }
    
    return 0;
}
コード例 #4
0
int main()
{
   secant_method(-0.999999, .999999);
   return 0;
}
コード例 #5
0
int main()
{
   secant_method(0, 1);
   secant_method(3, 5);
   return 0;
}