What is the PHP equivalent of these lines in R?

I am trying to migrate a script from R to PHP, but am not sure if lines 3 and 4 ( taken from the larger function discussed here ) do, It seems like logical operations and array definition at the same time. Can someone please give me the equivalent in PHP?

cosAzPos <- (0 <= sin(dec) - sin(el) * sin(lat))
sinAzNeg <- (sin(az) < 0)
az[cosAzPos & sinAzNeg] <- az[cosAzPos & sinAzNeg] + twopi
az[!cosAzPos] <- pi - az[!cosAzPos]
+3
source share
1 answer

I think it looks something like this:

if (0 < sin($dec) - sin($el) * sin($lat)) {
  if(sin($az) < 0)
    $az = $az + $twopi;
} 
else {
  $az = $pi - $az;
}

For lines 3-4 only:

if ($cosAzPos && $sinAzNeg) {
  $az = $az + $twopi;
}
elseif (!$cosAzPos) {
  $az = $pi - $az;
}
else {
  // leave $az value
}

according to commet, I found in the link. But I'm not sure about access to indexes in float

+2
source

All Articles