ivanshuba commented on code in PR #227:
URL: https://github.com/apache/commons-geometry/pull/227#discussion_r1471307137
##########
commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircle.java:
##########
@@ -338,7 +338,17 @@ public boolean eq(final GreatCircle other, final
Precision.DoubleEquivalence pre
/** {@inheritDoc} */
@Override
public int hashCode() {
- return Objects.hash(pole, u, v, getPrecision());
+ int result = 1;
+ long temp;
Review Comment:
> I think the current implementation is fine. What should be changed is the
test.
At present, there is only one assertion causing the test to fail. For these
two circles:
```java
final GreatCircle c = GreatCircles.fromPoleAndU(Vector3D.Unit.PLUS_Z,
Vector3D.Unit.MINUS_X, TEST_PRECISION);
final GreatCircle a = GreatCircles.fromPoleAndU(Vector3D.Unit.PLUS_Z,
Vector3D.Unit.PLUS_X, TEST_PRECISION);
```
The test currently assumes the hashes must not be equal.
```java
final int hash = a.hashCode();
Assertions.assertNotEquals(hash, c.hashCode());
```
I might be misunderstanding this point ( please help me clarify ), but it
appears that these two circles are topologically identical meaning they occupy
the same space.
If this interpretation is correct, we could simply modify the assumption and
assert that the hashes of these two circles are expected to be the same.
```java
Assertions.assertEquals(hash, c.hashCode());
```
With this small adjustment, the test should pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]