/*+JMJ * 3dplot.c - Print 2-D graph of 3-D function: * * z = f(x,y) = A * exp ((x**2 + y**2) / D) + B*y + C * * Ported from Creative Computing BASIC Games Collection * * 2015 David Meyer <papa@sdf.org> */ #include <stdio.h> #include <math.h> #include "krcompat.h" int main () { double x, ry, y; int l, z; printf ("%39s\n\n\n", "3DPLOT / SLOTS"); for (x = -30; x <= 30; x += 1.5) { char line[] = " "; l = 0; ry = 5 * floor (sqrt (900 - x*x) / 5); for (y = ry; y >= -ry; y -= 5) { z = (int) floor (30 * exp ((x*x + y*y) / -100.0) - 0.7*y + 25); if (z <= l) continue; l = z; line[z] = '*'; } printf ("%s\n", line); } exit (0); }