// Persistence Of Vision raytracer version 3.0 file. // File: 3d_math.pov // Vers: 1.0 // Desc: Plotting 3D Math Functions // Date: 03/28/1998 // Auth: Mark Arrasmith // // This is an example for sin(x^2 + y^2) // // To use this file for other 3d math functions just // change the x and y boundaries using Lower/Upper_X // and Lower/Upper_Y. Add your function to all the // Z_Pos_? declare statements. Note that here I am // treating z and pov's y coordinate to stick to // "normal" math conventions. // // Also, you will have to change the color functions // to account for whatever values you want. For // example you can take the (sin(Z_Pos_?))^2 or cosine // to make sure the values are between 0 and 1. // #version 3.0 global_settings { assumed_gamma 1.0 } #include "colors.inc" // ------------------------------------------------------------------ // Look down at an angle // ------------------------------------------------------------------ camera { location <2,4,-6> look_at <0,0,0> } // ------------------------------------------------------------------ // Simple background // ------------------------------------------------------------------ background { color rgb <1.0, 1.0, 1.0> } // ------------------------------------------------------------------ // A light source // ------------------------------------------------------------------ light_source{ <0,40,-15> White } // ------------------------------------------------------------------ // Set up the loop variables and intial boundary: // the Sc & Tc variable will go from 0 to Num_of_Points. // Also, we will use the "standard" axis for mathematics // where z is vertical and x,y are the plane. // ------------------------------------------------------------------ #declare Num_of_Points = 100 //grid in xy plane #declare Lower_X = -pi //Lower bound on x #declare Upper_X = pi //Upper bound on x #declare Diff_X = Upper_X - Lower_X //Width of x-coordinates #declare Delta_X = Diff_X/Num_of_Points #declare Lower_Y = -pi //Lower bound on y #declare Upper_Y = pi //Upper bound on y #declare Diff_Y = Upper_Y - Lower_Y //Width of y-coordinates #declare Delta_Y = Diff_Y/Num_of_Points // ------------------------------------------------------------------ // Create a surface built from our basic shape // first scan along the y-axis using Tc and then // along the x-axis using Sc // ------------------------------------------------------------------ // Sc goes from 0 to Num_of_Points #declare Sc = 0 #while (Sc, , texture { pigment { color rgb } finish { ambient .2 diffuse .6 phong .75 phong_size 150 } } } // Triangle ADC triangle { , , texture { pigment { color rgb } finish { ambient .2 diffuse .6 phong .75 phong_size 25 } } } // Calculate Point A by letting A = C #declare X_Pos_A = X_Pos_C #declare Y_Pos_A = Y_Pos_C #declare Z_Pos_A = Z_Pos_C // Calculate Point B by letting B = D #declare X_Pos_B = X_Pos_D #declare Y_Pos_B = Y_Pos_D #declare Z_Pos_B = Z_Pos_D // manually increment our counter inside the loop #declare Tc=Tc+1 #end // manually increment our counters inside the loop #declare Sc=Sc+1 #end