Vector3 implements ReadonlyVector3, Animates<ReadonlyVector3>, Serializable { @Override public boolean isInSphere(ReadonlyVector3 origin, double radius) { return Math.pow(x - origin.getX(), 2) + Math.pow(y - origin.getY(), 2) + Math.pow(z - origin.getZ(), 2) <= Math.pow(radius, 2); } Vector3();  Vector3(double x, double y, double z);  Vector3(ReadonlyVector3 other); @Override Vector3 copy(); @Override double getX(); @Override double getY(); @Override double getZ(); @Override double getComponent(Axis axis); @Override boolean componentEquals(Axis axis, double value, double epsilon); @Override boolean equalsExact(ReadonlyVector3 other); @Override boolean equalsExact(double otherX, double otherY, double otherZ); @Override boolean equals(ReadonlyVector3 other, double epsilon); @Override boolean equals(double otherX, double otherY, double otherZ, double epsilon); @Deprecated @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); @Override boolean isZero(); @Override double lengthSquared(); @Override double length(); @Override double distanceSquared(ReadonlyVector3 other); @Override @Deprecated double getDistanceSquared(ReadonlyVector3 other); @Override double distance(ReadonlyVector3 other); @Override @Deprecated double getDistance(ReadonlyVector3 other); @Override double dot(ReadonlyVector3 other); @Override double angle(ReadonlyVector3 other); @Override double angleDegrees(ReadonlyVector3 other); @Override double yaw(); @Override double yawDegrees(); @Override double pitch(); @Override double pitchDegrees(); @Override boolean isInAABB(ReadonlyVector3 lowerCorner, ReadonlyVector3 upperCorner); @Override boolean isInSphere(ReadonlyVector3 origin, double radius); @Override void glApplyRotateDegrees(double angleDegrees); @Override void glApplyRotateRadians(double angleRadians); @Override void glApplyScale(); @Override void glApplyTranslate(); Vector3 set(double x, double y, double z); Vector3 set(ReadonlyVector3 other); Vector3 setX(double x); Vector3 setY(double y); Vector3 setZ(double z); Vector3 setComponent(Axis axis, double value); Vector3 swapComponents(); Vector3 addX(double xAmount); Vector3 addY(double yAmount); Vector3 addZ(double zAmount); Vector3 addComponent(Axis axis, double amount); Vector3 add(double xAmount, double yAmount, double zAmount); Vector3 add(ReadonlyVector3 other); Vector3 subtract(ReadonlyVector3 other); Vector3 zero(); Vector3 setRandom(); Vector3 setMinimum(ReadonlyVector3 a, ReadonlyVector3 b); Vector3 setMaximum(ReadonlyVector3 a, ReadonlyVector3 b); Vector3 setFromYawPitch(double yaw, double pitch); Vector3 setFromYawPitchDegrees(double yawDegrees, double pitchDegrees); Vector3 scale(double factor); Vector3 scaleX(double factor); Vector3 scaleY(double factor); Vector3 scaleZ(double factor); Vector3 scaleComponent(Axis axis, double factor); Vector3 negate(); Vector3 absolute(); Vector3 clamp(double min, double max); Vector3 clampX(double min, double max); Vector3 clampY(double min, double max); Vector3 clampZ(double min, double max); Vector3 clampComponent(Axis axis, double min, double max); Vector3 truncate(); Vector3 floor(); Vector3 ceiling(); Vector3 round(); Vector3 midpoint(ReadonlyVector3 other); Vector3 interpolate(ReadonlyVector3 other, double alpha); Vector3 cross(ReadonlyVector3 other); Vector3 normalize(); @Override boolean isAnimating(); @Override Vector3 animateStop(); @Override Vector3 animateStart(ReadonlyVector3 toVector, long durationMs); Vector3 animateStart(double toX, double toY, double toZ, long durationMs); @Override Vector3 animateStartLoop(ReadonlyVector3 toVector, boolean reverse, long durationMs); Vector3 animateStartLoop(double toX, double toY, double toZ, boolean reverse, long durationMs); static final ReadonlyVector3 ZEROS; }
@Test public void testIsInSphere() { ReadonlyVector3 v = new Vector3(3.5, -23.0, 1324.0); for (double radius : new double[] {1.0, 0.01, 20.5, -20.5, 0.0}) { assertTrue(Vector3.ZEROS.isInSphere(Vector3.ZEROS, radius)); assertTrue(v.isInSphere(v, radius)); } assertTrue(v.isInSphere(v.copy().addX(5.0), 6.0)); assertTrue(v.isInSphere(v.copy().addX(5.0), 5.0)); assertFalse(v.isInSphere(v.copy().addX(5.0), 4.0)); assertFalse(v.isInSphere(v.copy().addX(5.0), -4.0)); assertTrue(v.isInSphere(v.copy().addX(5.0), -5.0)); assertTrue(v.isInSphere(v.copy().addX(5.0), -6.0)); }