Class Shape

java.lang.Object
de.bluecolored.bluemap.api.math.Shape

public class Shape extends Object
A shape consisting of 3 or more Vector2d-points on a plane.
  • Constructor Details

  • Method Details

    • getPointCount

      public int getPointCount()
      Getter for the amount of points in this shape.
      Returns:
      the amount of points
    • getPoint

      public Vector2d getPoint(int i)
      Getter for the point at the given index.
      Parameters:
      i - the index
      Returns:
      the point at the given index
    • getPoints

      public Vector2d[] getPoints()
      Getter for a copy of the points array.
      (A shape is immutable once created)
      Returns:
      the points of this shape
    • getMin

      public Vector2d 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

      public Vector2d 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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • createRect

      public static Shape createRect(Vector2d pos1, Vector2d pos2)
      Creates a Shape representing a rectangle spanning over pos1 and pos2
      Parameters:
      pos1 - one corner of the rectangle
      pos2 - the opposite corner of the rectangle
      Returns:
      the created Shape
    • createRect

      public static Shape createRect(double x1, double y1, double x2, double y2)
      Creates a Shape representing a rectangle spanning over two points
      Parameters:
      x1 - x position of one corner of the rectangle
      y1 - y position of one corner of the rectangle
      x2 - x position of the opposite corner of the rectangle
      y2 - y position of the opposite corner of the rectangle
      Returns:
      the created Shape
    • createEllipse

      public static Shape createEllipse(Vector2d centerPos, double radiusX, double radiusY, int points)
      Creates a Shape representing an ellipse.
      Parameters:
      centerPos - the center of the ellipse
      radiusX - the x radius of the ellipse
      radiusY - the y radius of the ellipse
      points - 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 a Shape representing an ellipse.
      Parameters:
      centerX - the x-position of the center of the ellipse
      centerY - the y-position of the center of the ellipse
      radiusX - the x radius of the ellipse
      radiusY - the y radius of the ellipse
      points - the amount of points used to create the ellipse (at least 3)
      Returns:
      the created Shape
    • createCircle

      public static Shape createCircle(Vector2d centerPos, double radius, int points)
      Creates a Shape representing a circle.
      Parameters:
      centerPos - the center of the circle
      radius - the radius of the circle
      points - the amount of points used to create the circle (at least 3)
      Returns:
      the created Shape
    • createCircle

      public static Shape createCircle(double centerX, double centerY, double radius, int points)
      Creates a Shape representing a circle.
      Parameters:
      centerX - the x-position of the center of the circle
      centerY - the y-position of the center of the circle
      radius - the radius of the circle
      points - the amount of points used to create the circle (at least 3)
      Returns:
      the created Shape
    • builder

      public static Shape.Builder builder()
      Creates a builder to build Shapes.
      Returns:
      a new builder