Package de.bluecolored.bluemap.api.math
Class Shape
java.lang.Object
de.bluecolored.bluemap.api.math.Shape
A shape consisting of 3 or more
Vector2d
-points on a plane.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Shape.Builder
builder()
Creates a builder to buildShape
s.static Shape
createCircle
(double centerX, double centerY, double radius, int points) Creates aShape
representing a circle.static Shape
createCircle
(Vector2d centerPos, double radius, int points) Creates aShape
representing a circle.static Shape
createEllipse
(double centerX, double centerY, double radiusX, double radiusY, int points) Creates aShape
representing an ellipse.static Shape
createEllipse
(Vector2d centerPos, double radiusX, double radiusY, int points) Creates aShape
representing an ellipse.static Shape
createRect
(double x1, double y1, double x2, double y2) Creates aShape
representing a rectangle spanning over two pointsstatic Shape
createRect
(Vector2d pos1, Vector2d pos2) Creates aShape
representing a rectangle spanning over pos1 and pos2boolean
getMax()
Calculates and returns the maximum corner of the axis-aligned-bounding-box of this shape.getMin()
Calculates and returns the minimum corner of the axis-aligned-bounding-box of this shape.getPoint
(int i) Getter for the point at the given index.int
Getter for the amount of points in this shape.Vector2d[]
Getter for a copy of the points array.
(A shape is immutable once created)int
hashCode()
-
Constructor Details
-
Shape
-
Shape
-
-
Method Details
-
getPointCount
public int getPointCount()Getter for the amount of points in this shape.- Returns:
- the amount of points
-
getPoint
Getter for the point at the given index.- Parameters:
i
- the index- Returns:
- the point at the given index
-
getPoints
Getter for a copy of the points array.
(A shape is immutable once created)- Returns:
- the points of this shape
-
getMin
Calculates and returns the minimum corner of the axis-aligned-bounding-box of this shape.- Returns:
- the min of the AABB of this shape
-
getMax
Calculates and returns the maximum corner of the axis-aligned-bounding-box of this shape.- Returns:
- the max of the AABB of this shape
-
equals
-
hashCode
public int hashCode() -
createRect
Creates aShape
representing a rectangle spanning over pos1 and pos2- Parameters:
pos1
- one corner of the rectanglepos2
- the opposite corner of the rectangle- Returns:
- the created
Shape
-
createRect
Creates aShape
representing a rectangle spanning over two points- Parameters:
x1
- x position of one corner of the rectangley1
- y position of one corner of the rectanglex2
- x position of the opposite corner of the rectangley2
- y position of the opposite corner of the rectangle- Returns:
- the created
Shape
-
createEllipse
Creates aShape
representing an ellipse.- Parameters:
centerPos
- the center of the ellipseradiusX
- the x radius of the ellipseradiusY
- the y radius of the ellipsepoints
- the amount of points used to create the ellipse (at least 3)- Returns:
- the created
Shape
-
createEllipse
public static Shape createEllipse(double centerX, double centerY, double radiusX, double radiusY, int points) Creates aShape
representing an ellipse.- Parameters:
centerX
- the x-position of the center of the ellipsecenterY
- the y-position of the center of the ellipseradiusX
- the x radius of the ellipseradiusY
- the y radius of the ellipsepoints
- the amount of points used to create the ellipse (at least 3)- Returns:
- the created
Shape
-
createCircle
Creates aShape
representing a circle.- Parameters:
centerPos
- the center of the circleradius
- the radius of the circlepoints
- the amount of points used to create the circle (at least 3)- Returns:
- the created
Shape
-
createCircle
Creates aShape
representing a circle.- Parameters:
centerX
- the x-position of the center of the circlecenterY
- the y-position of the center of the circleradius
- the radius of the circlepoints
- the amount of points used to create the circle (at least 3)- Returns:
- the created
Shape
-
builder
Creates a builder to buildShape
s.- Returns:
- a new builder
-