in reply to Clockwise or Counter-clockwise
sub direction{ local $_; push @_, $_[0]; $_ += $a->[0] * $b->[1] - $a->[1] * $b->[0] while ($a,$b)=(shift,$_[0]), @_; $_ < 0; } my @unitCubeAnti = ([0,0],[0,1],[1,1],[1,0]); print direction(@unitCubeAnti) ? 'Anticlockwise' : 'Clockwise'; my @unitCubeClock = reverse @unitCubeAnti; print direction(@unitCubeClock) ? 'Anticlockwise' : 'Clockwise';
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Clockwise or Counter-clockwise
by tall_man (Parson) on Feb 20, 2003 at 19:18 UTC |