-
Notifications
You must be signed in to change notification settings - Fork 1
Add Point2D library #6
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change here in the description only? Or implement Point / Vector separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just description I think.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A point doesn't have length.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a example of point only operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well observed! Again, this was partly inspired by QPointF::manhattanLength
.
Perhaps keeping both is reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[-Pi , +PI]?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these operators sufficient to do sorting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure! Three way comparisons are able to replace all relational comparators.
Co-authored-by: Bezaliel Silva <[email protected]>
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.