/** * Multiplies this instance by a scalar. * @param scalar The multiplier, or value which is to multiply this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the multiplication. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian multiply(double scalar) { return new Cartesian(m_x * scalar, m_y * scalar, m_z * scalar); }
/** * Adds the specified set of {@link Cartesian} coordinates to this instance. * @param other The addend, or value which is to be added to this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the addition. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian add(@Nonnull Cartesian other) { return new Cartesian(m_x + other.m_x, m_y + other.m_y, m_z + other.m_z); }
/** * Subtracts the specified set of {@link Cartesian} coordinates from this instance. * @param other The subtrahend, or value which is to be subtracted from this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the subtraction. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian subtract(@Nonnull Cartesian other) { return new Cartesian(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z); }
/** * Forms the cross product of the specified set of {@link Cartesian} coordinates with this instance. * @param other The set of {@link Cartesian} coordinates to cross with this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the product. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian cross(@Nonnull Cartesian other) { return new Cartesian(m_y * other.m_z - m_z * other.m_y, m_z * other.m_x - m_x * other.m_z, m_x * other.m_y - m_y * other.m_x); }
/** * Adds the specified set of {@link UnitCartesian} coordinates to this instance. * @param other The addend, or value which is to be added to this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the addition. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian add(@Nonnull UnitCartesian other) { return new Cartesian(m_x + other.m_x, m_y + other.m_y, m_z + other.m_z); }
/** * Multiplies this instance by a scalar. * @param scalar The multiplier, or value by which to multiply this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the multiplication. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian multiply(double scalar) { return new Cartesian(m_x * scalar, m_y * scalar, m_z * scalar); }
/** * Divides this instance by a scalar. * @param scalar The divisor, or value by which to divide this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the division. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian divide(double scalar) { return new Cartesian(m_x / scalar, m_y / scalar, m_z / scalar); }
/** * Subtracts the specified set of {@link Cartesian} coordinates from this instance. * @param other The subtrahend, or value which is to be subtracted from this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the subtraction. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian subtract(@Nonnull Cartesian other) { return new Cartesian(m_x - other.getX(), m_y - other.getY(), m_z - other.getZ()); }
/** * Converts a set of {@link UnitCartesian} coordinates to a set of {@link Cartesian} coordinates. * @param coordinates The set of {@link UnitCartesian} coordinates. * @return The resulting set of {@link Cartesian} coordinates. */ @CS2JInfo("This method implements the functionality of the implicit conversion operation 'Cartesian <= UnitCartesian'") @Nonnull public static Cartesian toCartesian(@Nonnull UnitCartesian coordinates) { return new Cartesian(coordinates.getX(), coordinates.getY(), coordinates.getZ()); }
/** * Adds the specified set of {@link Cartesian} coordinates to this instance. * @param other The addend, or value which is to be added to this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the addition. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian add(@Nonnull Cartesian other) { return new Cartesian(m_x + other.getX(), m_y + other.getY(), m_z + other.getZ()); }
/** * Forms the cross product of the specified set of {@link Cartesian} coordinates with this instance. * @param other The set of {@link Cartesian} coordinates to cross with this instance. * @return A set of {@link Cartesian} coordinates that represents the result of the product. */ @CS2JWarning("Unhandled attribute removed: Pure") @Nonnull public final Cartesian cross(@Nonnull Cartesian other) { return new Cartesian(m_y * other.getZ() - m_z * other.getY(), m_z * other.getX() - m_x * other.getZ(), m_x * other.getY() - m_y * other.getX()); }
/** * Tests thats the {@link Cartesian#equalsEpsilon} method returns true when the difference is exactly epsilon. */ @Test public final void testEqualsEpsilonExact() { Cartesian first = new Cartesian(0.1, 0.1, 0.1); Cartesian second = new Cartesian(0.1, 0.1, 0.1); Assert.assertTrue(second.equalsEpsilon(first, 0D)); }
/** * Tests that GetHashCode returns something at least reasonably random. */ @Test public final void testGetHashCode() { Cartesian object1 = new Cartesian(1.0, 2.0, 3.0); Cartesian object2 = new Cartesian(1.0, 2.0, 3.0); Cartesian object3 = new Cartesian(1.0, 2.0, 3.1); Assert.assertEquals((int) object1.hashCode(), (int) object2.hashCode()); AssertHelper.assertNotEqual(object1.hashCode(), object3.hashCode()); }
/** * Tests math operators */ @Test public final void testMathOperatorsWithCartesian() { Matrix3By3 test = new Matrix3By3(1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 4.0, 5.0, 6.0); Cartesian mult = new Cartesian(1D, 2D, 3D); Assert.assertTrue((new Cartesian(17D, 23D, 32D).equalsType(test.multiply(mult)))); Assert.assertTrue((new Cartesian(17D, 23D, 32D).equalsType(Matrix3By3.multiply(test, mult)))); }
/** * Tests the {@code Magnitude} ({@link Cartesian#getMagnitude get}) property. */ @Test public final void testMagnitude() { Cartesian test = new Cartesian(2.0, 3.0, 6.0); Assert.assertEquals(7.0, test.getMagnitude(), 0d); }
/** * Tests that normalization of a {@link Cartesian} with infinite magnitude produces an {@link ArithmeticException}. */ @Test public final void testNormalizeOfInfiniteMagnitude() { ExpectedExceptionHelper.expectException(getRule$expectedException(), ArithmeticException.class); Cartesian test = new Cartesian(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); UnitCartesian unit = test.normalize(); }
/** * Tests to ensure the equality fails when comparing incorrect type. */ @Test public final void testEqualityWithWrongType() { Matrix3By3 first = Matrix3By3.getIdentity(); Cartesian second = new Cartesian(1.0, 2.0, 3.0); Assert.assertFalse(first.equals(second)); }
/** * Tests to ensure the equality fails when comparing incorrect type. */ @Test public final void testEqualityWithWrongType() { Cartesian first = new Cartesian(1.0, 2.0, 3.0); Cartographic second = new Cartographic(1.0, 2.0, 3.0); Assert.assertFalse(first.equals(second)); }
/** * Tests the {@link Cartesian#normalize()} method. */ @Test public final void testNormalize() { Cartesian test = new Cartesian(2.0, 3.0, 6.0); UnitCartesian unit = test.normalize(); Assert.assertEquals(2.0 / 7.0, unit.getX(), 0d); Assert.assertEquals(3.0 / 7.0, unit.getY(), 0d); Assert.assertEquals(6.0 / 7.0, unit.getZ(), 0d); }