Platinum Partner

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";

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}