/** * Perform the HelmertTransform on a CartesianCoordinate. * * @param CartesianCoordinate $coordinate The CartesianCoordinate to transform. * * @return CartesianCoordinate The transformed CartesianCoordinate. */ public function transform(CartesianCoordinate $coordinate) { $x = $coordinate->getX(); $y = $coordinate->getY(); $z = $coordinate->getZ(); $tx = $this->translationX; $ty = $this->translationY; $tz = $this->translationZ; $rx = $this->getRotationXRadians(); $ry = $this->getRotationYRadians(); $rz = $this->getRotationZRadians(); // Normalise parts-per-million to (scaleFactor + 1). $s1 = $this->scaleFactor / '1e6' + 1; // Apply the transform. $x2 = $tx + $x * $s1 - $y * $rz + $z * $ry; $y2 = $ty + $x * $rz + $y * $s1 - $z * $rx; $z2 = $tz - $x * $ry + $y * $rx + $z * $s1; return new CartesianCoordinate($x2, $y2, $z2, clone $coordinate->getDatum()); }
public function testToStringMethodReturnsExpectedResult() { $x = 123.4; $y = 456.7; $z = 789.1; $instance = new CartesianCoordinate($x, $y, $z, $this->datumFactory->createDefault()); $expected = "{$x}, {$y}, {$z}"; $this->assertEquals($expected, $instance->toString()); }