Added equals/hashCode contract to Vector2D/Vector3D #482
No reviewers
Labels
No Label
bug
dependencies
discussion
documentation
duplicate
feature
good first issue
misc
performance
question
test
use case
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/kmath#482
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This changes add an explicit
equals
+hashCode
contract to bothVector2D
andVector3D
.Before this change, if one were to implement the
Vector3D
interface directly, it would violate the the symmetric and transitive aspects ofObject
/Any
'sequals
contract.A typical use case where one would implement the interface directly (compared to just using the provided data class) is to create a more natural adapter from some internal code base or other libraries to this one.
Think of an imaginary data type
MyVector
which has also represents a 3D vector using x, y and z components. By changingMyVector
to implementVector3D
, I immediately get access to all sorts of nice features from this library: extension functions, operators, rotations, etc.Comparing real-valued vectors seems to be a bad thing. You need to add a tolerance for any floating point number comarison. Also I would like to keep Vectors and other algebra elements as identity-free value-classes.
I would like to suggest introducing an algebra-based comparion like
EuclidianSpace2D.contentEquals(v1: Vector2D, v2 : Vector2D, tolerance: Double): Boolean
.See discussion in #470 and #248
Closing because of discussion above. Adding algebra-level methods would be appreciated.
Pull request closed