#!/usr/bin/perl -w

use strict;
use geomath;

my @xList = (1, 2, 5, 8, 6, 3,2);

my @yList = (2, 4, 2, 6, 9, 7, 9);

my $arrLength = scalar(@xList);

my $total = 0;

print "Question 1\n";
print " Circumference at 0: " . getEarthCircumference(0) . "\n";

print "Question 2\n";
foreach my $latitude(15, 35, 49, 75, 90) {
        print " Circumference at N$latitude: " . getEarthCircumference($latitude) . "\n";
}

print "Question 3\n";

print " " . spherical2cartesian((getLineLength(dms2dd("-75 42 00"), dms2dd("45 25 00"), 0, 0)), deg2rad(dms2dd("45 25 00")), deg2rad(
dms2dd("-75 42 00"))) . "\n";

print "Question 4\n";
print " Intersection point: " . lineIntersect(1, 3, 10, 7, 2, 7, 8, 2) . "\n";

print "Question 5\n";
print " Intersection point: " . lineIntersect(1, 1, 4, 5, 7, 6, 10, 3) . "\n";

print "Question 6\n";

my $intersectionPointq4 = lineIntersect(1, 3, 10, 7, 2, 7, 8, 2);
my $intersectionPointq5 = lineIntersect(1, 1, 4, 5, 7, 6, 10, 3);

print " $intersectionPointq4\n";

print getLineMidpoint(1, 3, 10, 7) . " ";
print getLineMidpoint(2, 7, 8, 2)  . "\n";

print " $intersectionPointq5\n";

print getLineMidpoint(1, 1, 4, 5) . " ";
print getLineMidpoint(7, 6, 10, 3) . "\n";

print "Question 7\n";

# implementation goes here

print "Question 8\n";
for(my $i = 0; $i < ($arrLength - 1); $i++) {
  my $nextEl = $i + 1;
  $total += getLineLength($xList[$i], $yList[$i], $xList[$nextEl], $yList[$nextEl]);
}

print " Total line length: $total\n";
