These formulas are for making a heart-shaped depth map, for use in constructing an autostereogram. In this part of the process, we’ll create a heart-shaped object. We’ll do it by modeling the heart as a combination of two spheres and parts of cylinders. That way it will have a nice curvature to it. Each formula shows a construction that has one more feature than the previous one. Each formula is self-contained, and it is only the final one that is really necessary to construct the heart depth-map. More discussion of these formulas can be found on the worksheet, "Making Valentine Stereograms." Also, the basic formulas for spheres and cylinders are described in the "Synthesizing Images" chapter of "Pixels, Numbers, and Programs." -- Steve Tanimoto, 2007. BEGIN FORMULA BARS 1#|#Sphere#|#512,256#|#*,*#|#255 - sqrt(sqr(w/8) - sqr(w/2-x) - sqr(h/2 - y)) #|#c#|#Here we take w/8 as the radius of the sphere.#|#100,100 2#|#Sphere-shifted#|#512,256#|#*,*#|#255 - sqrt(sqr(w/8) - sqr(0.375*w-x) - sqr(0.625*h - y)) #|#c#|##|#150,150 3#|#Modified Sphere#|#512,256#|#*,*#|#if sqr(0.375*w-x) + sqr(0.625*h - y) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr(0.375*w-x) - sqr(0.625*h - y)) else 255#|#c#|##|#200,200 4#|#The Sphere, Mirrored#|#512,256#|#4,*#|#If x < w/2 then If sqr(0.375*w-x) + sqr(0.625*h - y) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr(0.375*w-x) - sqr(0.625*h - y)) else 255 else S1(xmax - x,y)#|#c#|##|#250,250 5#|#Cylinder tilted#|#512,256#|#*,*#|#255 - sqrt((sqr(w/8) - Sqr((h - x - y)/1.414)))#|#c#|##|#300,300 6#|#Cylinder, shifted#|#512,256#|#*,*#|#255 - sqrt((sqr(w/8) - Sqr((0.375*w + 0.625*h - x - y)/1.414)))#|#c#|##|#350,350 7#|#Cylinder, White background#|#512,256#|#*,*#|#If sqr((0.375*w + 0.625*h - x - y)/1.414) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr((0.375*w + 0.625*h - x - y)/1.414)) else 255#|#c#|##|#400,400 8#|#Cylinder, Trimmed#|#512,256#|#*,*#|#if y < x-0.125*h then if sqr((0.375*w + 0.625*h - x - y)/1.414) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr((0.375*w + 0.625*h - x - y)/1.414)) else 255 else 255#|#c#|##|#50,100 9#|#Cylinder, Ball, Blended#|#512,256#|#*,*#|#Min(If sqr(0.375*w-x) + sqr(0.625*h - y) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr(0.375*w-x) - sqr(0.625*h - y)) else 255, if y < x-0.125*h then If sqr((0.375*w + 0.625*h - x - y)/1.414) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr((0.375*w + 0.625*h - x - y)/1.414)) else 255 else 255) #|#c#|##|#100,150 10#|#Complete Heart#|#512,256#|#9,*#|#If x < w/2 then min(if sqr(0.375*w-x) + sqr(0.625*h - y) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr(0.375*w-x) - sqr(0.625*h - y)) else 255, if y < x-0.125*h then If sqr((0.375*w + 0.625*h - x - y)/1.414) < sqr(w/8) then 255 - sqrt(sqr(w/8) - sqr((0.375*w + 0.625*h - x - y)/1.414)) else 255 else 255) else s1(xmax-x,y)#|#c#|#The final product, ready for use in stereogram making!#|#150,200