displacement olympicdisp( float radius = 0.160, /* outer radius */ thick = 0.050, /* dist to inner radius */ disp = 0.300 /* displacement */ ) { float theta; /* used to make a cosine curve displacement */ float r; /* dist to center of ring */ float height = 0.0; /* height to displace */ float dt = 0.0; /* distance from inner ring */ /* centers of the circles in (s,t) space: */ point pblue = point ( 0.250, 0.600, 0.0 ); point pyellow = point ( 0.375, 0.400, 0.0 ); point pblack = point ( 0.500, 0.600, 0.0 ); point pgreen = point ( 0.625, 0.400, 0.0 ); point pred = point ( 0.750, 0.600, 0.0 ); /* where we are right now in (s,t) space: */ point here = point ( s, t, 0.0 ); /* are we within the blue ring? */ r = distance( here, pblue ); if( (radius-thick) <= r && r <= radius ) { height = disp; dt = r - (radius - thick); } /* are we within the yellow ring? */ r = distance( here, pyellow ); if( (radius-thick) <= r && r <= radius ) { height = disp; dt = r - (radius - thick); } /* are we within the black ring? */ r = distance( here, pblack ); if( (radius-thick) <= r && r <= radius ) { height = disp; dt = r - (radius - thick); } /* are we within the green ring? */ r = distance( here, pgreen ); if( (radius-thick) <= r && r <= radius ) { height = disp; dt = r - (radius - thick); } /* are we within the red ring? */ r = distance( here, pred ); if( (radius-thick) <= r && r <= radius ) { height = disp; dt = r - (radius - thick); } /* do the cosine computation: */ theta = 2.*PI*dt/thick - PI; height = height * ( 1. + cos(theta) ) / 2.; /* displace the point: */ P = P + height * normalize( N ); N = calculatenormal( P ); }