Skip to content

Commit

Permalink
use magnover to replace some equivalent expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 30, 2024
1 parent 9c420d6 commit cb6d0e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Graphics/TriD/TriD/MathGraph.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sub step {
my $tst = 0.10;
$this->{Velo} = ($this->{Velo}//0) + $tst * 0.02 * ($velr + $vela);
$this->{Velo} *=
((0.92*50/(50+sqrt(($this->{Velo}**2)->sumover->dummy(0)))))**$tst;
(0.92*50/(50+$this->{Velo}->magnover->dummy(0)))**$tst;
$c += $tst * 0.05 * $this->{Velo};
(my $tmp = $c->transpose->index($this->{FInd}->dummy(0)))
.= $this->{FCoord}
Expand Down
10 changes: 5 additions & 5 deletions Libtmp/Transform/Cartography/Cartography.pm
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ sub t_unit_sphere {
my($d,$o) = @_;

my($d0,$d1,$d2) = ($d->slice("(0)"),$d->slice("(1)"),$d->slice("(2)"));
my($r) = sqrt(($d->slice("0:2")*$d->slice("0:2"))->sumover);
my($r) = $d->slice("0:2")->magnover;
my(@dims) = $d->dims;
$dims[0]--;
my($out) = zeroes(@dims);
Expand Down Expand Up @@ -2232,7 +2232,7 @@ sub t_az_eqd {
my($x) = $d->slice("(0)");
my($y) = $d->slice("(1)");
my $rho = sqrt(($d->slice("0:1")*$d->slice("0:1"))->sumover);
my $rho = $d->slice("0:1")->magnover;
# Order is important -- ((0)) overwrites $x if is_inplace!
$out->slice("(0)") .= atan2( $x * sin($rho), $rho * cos $rho );
$out->slice("(1)") .= asin( $y * sin($rho) / $rho );
Expand Down Expand Up @@ -2578,7 +2578,7 @@ sub t_vertical {
$out->slice("0:1") *= ($P - 1.0) * ($o->{f} ? 1.0 : $o->{tconv})
if($o->{t});
my($rho) = sqrt(sumover($d->slice("0:1") * $d->slice("0:1")));
my $rho = $d->slice("0:1")->magnover;
my($sin_c) = ( ( $P - sqrt( 1 - ($rho*$rho * ($P+1)/($P-1)) ) ) /
( ($P-1)/$rho + $rho/($P-1) )
);
Expand Down Expand Up @@ -2917,7 +2917,7 @@ sub t_perspective {
## Apply the tangent-plane transform, and scale by the magnification.
my $dcyz = $dc->slice("1:2");
my $r = ( $dcyz * $dcyz ) -> sumover -> sqrt ;
my $r = $dcyz->magnover;
my $rscale;
if( $o->{mag} == 1.0 ) {
$rscale = - 1.0 / $dc->slice("(0)");
Expand Down Expand Up @@ -2969,7 +2969,7 @@ sub t_perspective {
## Inverse-magnify if required
if($o->{mag} != 1.0) {
my $r = ($oyz * $oyz)->sumover->sqrt;
my $r = $oyz->magnover;
my $scale = tan( atan( $r ) / $o->{mag} ) / $r;
$out->slice("0:1") *= $scale->dummy(0,1);
}
Expand Down

0 comments on commit cb6d0e9

Please sign in to comment.