Skip to content

Commit

Permalink
feat(geom): create Rectangled/f from point (and set to point) (#16)
Browse files Browse the repository at this point in the history
* test(geom): test Rectangled/f created from point
* doc(geom): update docstrings for Rectangled/f based on review
  • Loading branch information
skaldarnar authored Jan 26, 2021
1 parent dfb32b1 commit e3baf19
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 99 deletions.
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 the given point <code>(x, y)</code> with zero size.
*
* @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 the given <code>point</code> with zero size.
*
* @param point the coordinate of both minimum and maximum corner
* @return this
*/
public Rectangled set(Vector2fc point) {
return set(point.x(), point.y());
}

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

0 comments on commit e3baf19

Please sign in to comment.