public function applyTransform(Transform $transform) { $rx = Misc::toRadians($transform->getRx() / 3600); // normalise seconds to radians $ry = Misc::toRadians($transform->getRy() / 3600); // normalise seconds to radians $rz = Misc::toRadians($transform->getRz() / 3600); // normalise seconds to radians $s1 = $transform->getS() / 1000000.0 + 1; // normalise ppm to (s+1) $x2 = $transform->getTx() + $this->x * $s1 - $this->y * $rz + $this->z * $ry; $y2 = $transform->getTy() + $this->x * $rz + $this->y * $s1 - $this->z * $rx; $z2 = $transform->getTz() - $this->x * $ry + $this->y * $rx + $this->z * $s1; return new Vector($x2, $y2, $z2); }
/** @return Vector */ public function toCartesian() { $Glat = Misc::toRadians($this->lat); $Glng = Misc::toRadians($this->lng); $h = 0; // height above ellipsoid - not currently used $a = $this->datum->getEllipsoid()->getA(); $b = $this->datum->getEllipsoid()->getB(); $sinGlat = sin($Glat); $cosGlat = cos($Glat); $sinGlng = sin($Glng); $cosGlng = cos($Glng); $eSq = ($a * $a - $b * $b) / ($a * $a); $v = $a / sqrt(1 - $eSq * $sinGlat * $sinGlat); $x = ($v + $h) * $cosGlat * $cosGlng; $y = ($v + $h) * $cosGlat * $sinGlng; $z = ((1 - $eSq) * $v + $h) * $sinGlat; return new Vector($x, $y, $z); }