Conversation
robocin/geometry/README.md
Outdated
| - `value_type dot(const Point2D& other) const`: Computes the dot product of the current point and another point. | ||
| - `value_type cross(const Point2D& other) const`: Computes the cross product of the current point and another point. |
There was a problem hiding this comment.
Dot and cross are common vectors operations. Some operations are specific for vector or point interpretation, hardly for both.
There was a problem hiding this comment.
Should I change here in the description only? Or implement Point / Vector separately?
robocin/geometry/README.md
Outdated
| - `value_type manhattanLength() const`: Computes the Manhattan distance between the origin and the current point. | ||
| - `value_type lengthSquared() const`: Computes the square of the Euclidean length of the current point. | ||
| - `auto length() const`: Computes the Euclidean length of the current point. | ||
| - `auto norm() const`: Computes the Euclidean length of the current point. |
robocin/geometry/README.md
Outdated
|
|
||
| - `value_type dot(const Point2D& other) const`: Computes the dot product of the current point and another point. | ||
| - `value_type cross(const Point2D& other) const`: Computes the cross product of the current point and another point. | ||
| - `value_type manhattanLength() const`: Computes the Manhattan distance between the origin and the current point. |
There was a problem hiding this comment.
I dont like that. So for manhattan that commonly a binary function, I have to do:
(b-a).manhattanLength()
Instead of:
a.manhattanDistance(b)?
I think that manhattan is more related to distance than length.
There was a problem hiding this comment.
Very well observed! Again, this was partly inspired by QPointF::manhattanLength.
Perhaps keeping both is reasonable?
robocin/geometry/README.md
Outdated
| - `auto angle() const`: Computes the angle (in radians) between the positive x-axis and the vector from the origin to | ||
| the current point. |
robocin/geometry/README.md
Outdated
|
|
||
| ### Validators | ||
|
|
||
| - `bool isNull() const`: Checks if the point is null (coordinates are both zero). Returns `true` |
There was a problem hiding this comment.
| - `bool isNull() const`: Checks if the point is null (coordinates are both zero). Returns `true` | |
| - `bool isOrigin() const`: Checks if the point is null (coordinates are both zero). Returns `true` |
discard null word for this case.
There was a problem hiding this comment.
It was originally inspired on QPointF::isNull, but I agree that isOrigin looks better for this purpose...
However, perhaps isNull is a common interface for other geometric representations such as QRectF, QVector3D...
wdyt?
robocin/geometry/README.md
Outdated
| - `bool operator==(const Point2D& other) const`: Equality operator that checks if two points are equal. | ||
| - `auto operator<=>(const Point2D& other) const`: Three-way comparison operator that compares two points and returns | ||
| their relative ordering. |
There was a problem hiding this comment.
Are these operators sufficient to do sorting?
There was a problem hiding this comment.
For sure! Three way comparisons are able to replace all relational comparators.
Co-authored-by: Bezaliel Silva <33490486+bcs5@users.noreply.github.com>
480c2b3 to
43ca90f
Compare
This pull request introduces the Point2D library, providing a versatile and efficient implementation of a 2D point structure. The Point2D library offers various mathematical operations and geometric functions that can be utilized in a wide range of applications.