# this works as a bash include
#
#PRIO 1.1
#COMM test specialised constructors Math::GeometNdTrform->new_*()
#COMM - test results over a parallelogram of transformations
#
perl -e '
  use lib shift();  # give include precedence to code directory, perl -I would not work!
  use strict;
  use Math::GeometNdPoint;
  use Math::GeometNdTrform;
  my $ndim=3;
  my $pi=3.14159265358979;
  my $pVec1=Math::GeometNdPoint->new($ndim,[1,0,1]);
  printf "argument point: %s\n", $pVec1->string(-fmtfloat=>q(%.1f));
  print  "-----\n";
  my $pVecH=Math::GeometNdPoint->new($ndim,[0,1,1]);
  my $pTrf1 = Math::GeometNdTrform->new_move($ndim,-2*$pVecH)
    or die "Math::GeometNdTrform->new_move(...) failed";
  printf "move: %s\n", $pTrf1->string(-fmtfloat=>q(%.1f));
  my $pTrf2 = Math::GeometNdTrform->new_stretch($ndim,2)
    or die "Math::GeometNdTrform->new_stretch(...) failed";
  printf "stretching: %s\n", $pTrf2->string(-fmtfloat=>q(%.1f));
  my $pTrf3 = Math::GeometNdTrform->new_rotate($ndim,0,1,0.5*$pi)
    or die "Math::GeometNdTrform->new_rotate(...) failed";
  printf "rotation: %s\n", $pTrf3->string(-fmtfloat=>q(%.1f));
  my $pTrfS = $pTrf1 x $pTrf2;
  printf "transformation sequence (steps 1,2): %s\n", $pTrfS->string(-fmtfloat=>q(%.1f));
  my $pTrfS = $pTrf2 x $pTrf3 x $pTrf1;
  printf "transformation sequence (steps 2,3,1): %s\n", $pTrfS->string(-fmtfloat=>q(%.1f));
  print  "-----\n";
  my $pVecR = $pVec1->transform($pTrfS);
  printf "transformed point: %s - %s\n", $pVecR->string(-fmtfloat=>q(%.1f)),
    ($pVecR->amount()<1e-5) ? q(OK):q(ERROR);
  printf "argument point, control: %s\n", $pVec1->string(-fmtfloat=>q(%.1f));
  ' -- "$dircode"
