Skip to content

Commit

Permalink
feat: add 'getMin'/'getMax' to Rectangled/f/i
Browse files Browse the repository at this point in the history
  • Loading branch information
skaldarnar committed Apr 1, 2021
1 parent 145d337 commit 3436bfc
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,30 @@ public interface Rectangledc {

double minY();

/**
* Return the minimum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2d getMin(Vector2d dest) {
return dest.set(minX(), minY());
}

double maxX();

double maxY();

/**
* Return the maximum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2d getMax(Vector2d dest) {
return dest.set(maxX(), maxY());
}

/**
* Return the length of the rectangle in the X dimension.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package org.terasology.joml.geom;

import org.joml.Math;
import org.joml.Vector2d;
import org.joml.Vector2dc;
import org.joml.Vector2f;
import org.joml.Vector2fc;
Expand All @@ -14,10 +15,30 @@ public interface Rectanglefc {

float minY();

/**
* Return the minimum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2f getMin(Vector2f dest) {
return dest.set(minX(), minY());
}

float maxX();

float maxY();

/**
* Return the maximum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2f getMax(Vector2f dest) {
return dest.set(maxX(), maxY());
}

/**
* Return the length of the rectangle in the X dimension.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.joml.geom;

import org.joml.Vector2d;
import org.joml.Vector2dc;
import org.joml.Vector2fc;
import org.joml.Vector2i;
Expand All @@ -13,10 +14,30 @@ public interface Rectangleic {

int minY();

/**
* Return the minimum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2i getMin(Vector2i dest) {
return dest.set(minX(), minY());
}

int maxX();

int maxY();

/**
* Return the maximum corner of this rectangle.
*
* @param dest will hold the result
* @return dest
*/
default Vector2i getMax(Vector2i dest) {
return dest.set(maxX(), maxY());
}

/**
* Return the length of the rectangle in the X dimension.
*
Expand Down

0 comments on commit 3436bfc

Please sign in to comment.