in reply to Re^4: The problem of getting the unit vector "Undefined subroutine &main::Normalize"
in thread The problem of getting the unit vector "Undefined subroutine &main::Normalize"
If you know the formula (i.e., how to create the result by hand) you shouldn't have any difficulty in creating the subroutine yourself. What difficulty are you having with it?
As I see it, you'd start with something like:
sub Normalize { my $v = shift; my $vSquared = InProduct($v, $v); my $divisor = ... square root of sum of components of vSquared ... my $newVec1 = ... vector created by components of v divided by posi +tive divisor ... my $newVec2 = ... vector created by componets of v divided by negat +ive divisor ... .... whatever else is needed ... return $stuff; } my @dipoleMomentVectors = Normalize($dipoleMoment);
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: The problem of getting the unit vector "Undefined subroutine &main::Normalize"
by windcrazy86 (Novice) on Aug 31, 2017 at 20:34 UTC |