Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geom): create Rectangled/f from point (and set to point) #16

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ public Rectangled(double minX, double minY, double maxX, double maxY) {
this.maxY = maxY;
}

/**
* Create a new {@link Rectangled} of size zero at the given point.
*
* @param x the x coordinate of both minimum and maximum corner
* @param y the y coordinate of both minimum and maximum corner
*/
public Rectangled(double x, double y) {
this.minX = x;
this.minY = y;
this.maxX = x;
this.maxY = y;
}

/**
* Create a new {@link Rectangled} of size zero at the given point.
*
* @param point the coordinate of both minimum and maximum corner
*/
public Rectangled(Vector2dc point) {
this(point.x(), point.y());
}

@Override
public double minX() {
return this.minX;
Expand Down Expand Up @@ -170,6 +192,31 @@ public Rectangled set(Rectangled source){
return this;
}

/**
* Set this rectangle to be a clone of <code>source</code>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this comment needs updating

*
* @param x the x coordinate of both minimum and maximum corner
* @param y the y coordinate of both minimum and maximum corner
* @return this
*/
public Rectangled set(double x, double y) {
this.minX = x;
this.minY = y;
this.maxX = x;
this.maxY = y;
return this;
}

/**
* Set this rectangle to be a clone of <code>source</code>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Set this rectangle to be a clone of <code>source</code>.
* Set this rectangle to be a clone of <code>point</code>.

*
* @param point the coordinate of both minimum and maximum corner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in line with the other two. Or rather they with this respectively.

* @return this
*/
public Rectangled set(Vector2fc point) {
return set(point.x(), point.y());
}

/**
* Set the minimum corner coordinates.
*
Expand Down
Loading