#!/usr/bin/perl -w

use Math::MatrixReal;
$theta = atan2(1,1);    #  45 degrees in radians

@triangle = (Math::MatrixReal->new_from_string("[ -1 ]\n[ -1 ]\n"),
             Math::MatrixReal->new_from_string("[  0 ]\n[  1 ]\n"),
             Math::MatrixReal->new_from_string("[  1 ]\n[ -1 ]\n"));

# Create the rotation matrix.
$rotate = Math::MatrixReal->new_from_string("[ " .
                     cos($theta) . " " .  -sin($theta) . " ]\n" . "[ " .
                     sin($theta) . " " .   cos($theta) . " ]\n");

# Rotate the triangle by 45 degrees.

foreach (@triangle) {
    $_ = $rotate * $_;
    print "$_\n";
}
