DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Using Perl's Math-class
A little demo that shows how to perform some vector-algebra using Math::-methods.
#!/usr/bin/perl #use strict; use Math::VectorReal qw( :all ); use Math::Trig qw( acos ); $a=vector(10,0,0.1); $b=vector(0,0,1); $lnorm=($a->length)*($b->length); $scalprod= $a . $b; $arccosthis=$scalprod/$lnorm; $rangle=acos($arccosthis); $dangle=($rangle/3.1415926535897931)*180; print $a."".$b."\n"; print "Angle = ".$dangle."\n";





