Hi all. This isn't a very well known module, nor well documented (In my google-ing experience). Any ideas would be appreciated. This is my script:
#!/usr/bin/perl use strict; use warnings; use Math::Vector::Real; use constant DEG_PER_RAD => 45 / atan2(1, 1); my ( $source, $out ) = qw/ IN OUT /; open my $in_fh, '<', $source or die qq{Unable to open "$source" for i +nput: $!\n}; open my $out_fh, '>', $out or die qq{Unable to open "$out" for outp +ut: $!\n}; #select $out_fh; my @data; push @data, V(split) while <$in_fh>; for my $i ( 0 .. $#data-1 ) { for my $j ( $i+1 .. $#data ) { my $val1 = $data[$i]; my $val2 = $data[$j]; my $comp1 = $val1->[0]; my $comp2 = $val2->[0]; my $vect1 = $val1->[3..5]; my $vect2 = $val2->[3..5]; my $norm = $val1->[0..2]; my $nvect1 = $vect1 - $norm ; my $nvect2 = $vect1 - $norm ; if( $comp1 != $comp2 ){ next;}else{ my $degrees = atan2($nvect1, $nvect2) * DEG_PER_RA +D; print "$degrees\n"; } } }
In essence, the script reads the input and assigns each line to a vector via the Math::Vector::Real module. My input file is like so:
2 2 2 5 -2 1 2 2 2 2 7 4 5 2 2 2 7 4
Which are location coordinates. The first 3 numbers on each line correspond to a point, and the other 3 in the line correspond to a nearby point. The first set will often be identical from line to line. The second set will never repeat between consecutive lines like the first. I'm trying to find the angle between the second set of coordinates between two separate rows, after normalizing them with respect to the first set of coordinates. The script works (via print testing) up until  my $vect1 = $val1->[3..5];. When I print test here, I get:  2 (And a whole host of other errors that stem from this) I cannot find out how to split the values of a vector off into a new vector like I'm trying to. Does anyone have any ideas? Thanks.

In reply to Vector manipulation by jcklasseter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.