/** * Convert (face, si, ti) coordinates (see s2.h) to a direction vector (not * necessarily unit length). */ private static function faceSiTiToXYZ($face, $si, $ti) { $kScale = 1.0 / self::MAX_SIZE; $u = S2Projections::stToUV($kScale * $si); $v = S2Projections::stToUV($kScale * $ti); return S2Projections::faceUvToXyz($face, $u, $v); }
private function init(S2CellId $id) { $this->cellId = $id; $ij = array(0, 0); $mOrientation = 0; // echo " $mOrientation\n"; $this->face = $id->toFaceIJOrientation($ij[0], $ij[1], $mOrientation); // echo ">> $mOrientation\n"; $this->orientation = $mOrientation; $this->level = $id->level(); $cellSize = 1 << S2CellId::MAX_LEVEL - $this->level; for ($d = 0; $d < 2; ++$d) { // Compute the cell bounds in scaled (i,j) coordinates. $sijLo = ($ij[$d] & -$cellSize) * 2 - self::MAX_CELL_SIZE; $sijHi = $sijLo + $cellSize * 2; $this->uv[$d][0] = S2Projections::stToUV(1.0 / self::MAX_CELL_SIZE * $sijLo); $this->uv[$d][1] = S2Projections::stToUV(1.0 / self::MAX_CELL_SIZE * $sijHi); } }