Reputation: 7587
I'm trying to port a script from R into PHP but not sure what lines 3 and 4 (taken from the larger function discussed here) are doing. Looks 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]
Upvotes: 3
Views: 199
Reputation: 1122
I think it looks something like:
if (0 < sin($dec) - sin($el) * sin($lat)) {
if(sin($az) < 0)
$az = $az + $twopi;
}
else {
$az = $pi - $az;
}
Only for lines 3-4:
if ($cosAzPos && $sinAzNeg) {
$az = $az + $twopi;
}
elseif (!$cosAzPos) {
$az = $pi - $az;
}
else {
// leave $az value
}
according to commet I found in referenced post. But I not sure about accessing indexes in float
Upvotes: 2