From 16a80064d9e0ce983fa4eeb8b610f062a2652290 Mon Sep 17 00:00:00 2001 From: NezumiRonin Date: Tue, 23 Feb 2021 00:14:05 -0600 Subject: [PATCH] Create 3dplot.pl 3D Plot made with perl! --- 87 3-D Plot/perl/3dplot.pl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 87 3-D Plot/perl/3dplot.pl diff --git a/87 3-D Plot/perl/3dplot.pl b/87 3-D Plot/perl/3dplot.pl new file mode 100644 index 00000000..a7cfb1c6 --- /dev/null +++ b/87 3-D Plot/perl/3dplot.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl +use strict; +use warnings; + +print ' 'x32 ."3D PLOT\n"; +print ' 'x15 ."CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n"; +print "\n\n\n"; + +sub FNA { + my ($Z)= @_; + return 30*exp(-$Z*$Z/100); + } + +print "\n"; + +for (my $X=-30; $X<=30; $X+=1.5) { + my $L=0; + my $Line=" "x80; #Empty buffer string; + my $Y1=5*int(sqrt(900-$X*$X)/5); + for (my $Y=$Y1; $Y>=-$Y1; $Y-=5) { + my $Z=int(25+&FNA(sqrt($X*$X+$Y*$Y))-.7*$Y); + if ($Z<=$L) { next; } + $L= $Z; + substr $Line, $Z, 1, "*"; #Plot on the line by sustitution. + } + print "$Line\n"; #Now print the line. + }