# C(cx,cy)* ****** *D(?x,?y) # * * # * * # A(ax,ay)* ****** * B(bx,by) use strict; use warnings; use Data::Dump qw(dump); use Math::Trig; my @points = ( 1,5, #point A 5,5, #point B 1,9, #point C ); my @new =( 5,9); #point D will be given by user later (testing my theory) #lets' get the length of each segment; if parallel sides are equal #plus #test for 90 angles and IT's a rectangle or square # GET LENGTHS : #from A to B my $ABx= $points[2]-$points[0]; my $ABy= $points[3]-$points[1]; #points from A to C my $ACx= $points[4]-$points[0]; my $ACy= $points[5]-$points[1]; #get length to new points from C TO D my $CDx= $new[0]-$points[4]; my $CDy= $new[1]-$points[5]; #from B to D my $BDx= $new[0]-$points[2]; my $BDy= $new[1]-$points[3]; #test if lengths are the same #if so, then test if all angles are 90 if ($ABx == $CDx && $ACy == $BDy){ #find angle my $a= atan($ABx/$ACy)*(360/pi); $a==90 ? print "this is a Rectangle/square\n" : print "this is a rhombus of some sort\n"; }else { print " This shape doesn't have congruent sides; NOT a RECTANGLE or Square";}