Class Geometry

java.lang.Object
mathvoyage.geometry.Geometry

public class Geometry extends Object
voyager.geometry.java
Author:
Tahsin Islam
  • Method Details

    • getInstance

      public static Geometry getInstance()
      Returns the singleton instance of this class.
      Returns:
      The singleton instance
    • distanceCartesian

      public double distanceCartesian(Point p1, Point p2)
      Returns the distance between two points in cartesian coordinates.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The distance between the two points in cartesian coordinates
    • distancePolar

      public double distancePolar(Point p1, Point p2)
      Returns the distance between two points in polar coordinates.
      Parameters:
      p1 - The first point in polar coordinates
      p2 - The second point in polar coordinates
      Returns:
      The distance between the two points in polar coordinates
    • manhattanDistance

      public double manhattanDistance(Point p1, Point p2)
      Returns the manhattan distance between two points in cartesian coordinates.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The manhattan distance between the two points in cartesian coordinates
    • chebyshevDistance

      public double chebyshevDistance(Point p1, Point p2)
      Returns the chebyshev distance between two points.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The chebyshev distance between the two points
    • slope

      public double slope(Point p1, Point p2)
      Returns the slope of a line between two points.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The slope of the line between the two points
    • midpoint

      public Point midpoint(Point p1, Point p2)
      Returns the midpoint of a line between two points.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The midpoint of the line between the two points
    • centroid

      public Point centroid(Point p1, Point p2, Point p3)
      Returns the centroid of a triangle.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      The centroid of the triangle
    • areaOfTriangle

      public double areaOfTriangle(Point p1, Point p2, Point p3)
      Returns the area of a triangle inputted in anti-clockwise order.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      The area of the triangle
    • interleaverPoint

      public Point interleaverPoint(Point p1, Point p2, double m, double n)
      Returns the interleaver point of two points that divides the connecting line in a ratio of m:n.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      m - The ratio of the first point
      n - The ratio of the second point
      Returns:
      The interleaver point of the two points
    • externalizerPoint

      public Point externalizerPoint(Point p1, Point p2, double m, double n)
      Returns the ent
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      m - The ratio of the first point
      n - The ratio of the second point
      Returns:
      The externalizer point of the two points
    • areaOfQuadrilateral

      public double areaOfQuadrilateral(Point p1, Point p2, Point p3, Point p4)
      Returns the area of a quadrilateral using points inputted in anti-clockwise order.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      p4 - The fourth point in cartesian coordinates
      Returns:
      The area of the quadrilateral
    • areaOfCircle

      public double areaOfCircle(Point p1, Point p2)
      Returns the area of a circle.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The area of the circle
    • circumferenceOfCircle

      public double circumferenceOfCircle(Point p1, Point p2)
      Returns the circumference of a circle.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      Returns:
      The circumference of the circle
    • isEquilateralTriangle

      public boolean isEquilateralTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a equilateral triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a equilateral triangle, false otherwise
    • isIsoscelesTriangle

      public boolean isIsoscelesTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a isosceles triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a isosceles triangle, false otherwise
    • isScaleneTriangle

      public boolean isScaleneTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a scalene triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a scalene triangle, false otherwise
    • isRightTriangle

      public boolean isRightTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a right triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a right triangle, false otherwise
    • isObtuseTriangle

      public boolean isObtuseTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a obtuse triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a obtuse triangle, false otherwise
    • isAcuteTriangle

      public boolean isAcuteTriangle(Point p1, Point p2, Point p3)
      Returns if the triangle is a acute triangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      Returns:
      True if the triangle is a acute triangle, false otherwise
    • angleBetweenTwoSlopes

      public double angleBetweenTwoSlopes(double m1, double m2)
      Returns the angle between two slopes.
      Parameters:
      m1 - The first slope
      m2 - The second slope
      Returns:
      The angle between the two slopes
    • isRectangle

      public boolean isRectangle(Point p1, Point p2, Point p3, Point p4)
      Returns if the quadrilateral is a rectangle or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      p4 - The fourth point in cartesian coordinates
      Returns:
      True if the quadrilateral is a rectangle, false otherwise
    • isSquare

      public boolean isSquare(Point p1, Point p2, Point p3, Point p4)
      Returns if the quadrilateral is a square or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      p4 - The fourth point in cartesian coordinates
      Returns:
      True if the quadrilateral is a square, false otherwise
    • isParallelogram

      public boolean isParallelogram(Point p1, Point p2, Point p3, Point p4)
      Returns if the quadrilateral is a parallelogram or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      p4 - The fourth point in cartesian coordinates
      Returns:
      True if the quadrilateral is a parallelogram, false otherwise
    • isRhombus

      public boolean isRhombus(Point p1, Point p2, Point p3, Point p4)
      Returns if the quadrilateral is a rhombus or not.
      Parameters:
      p1 - The first point in cartesian coordinates
      p2 - The second point in cartesian coordinates
      p3 - The third point in cartesian coordinates
      p4 - The fourth point in cartesian coordinates
      Returns:
      True if the quadrilateral is a rhombus, false otherwise
    • isSameLine

      public boolean isSameLine(Line l1, Line l2)
      Returns if the two given lines are same or not
      Parameters:
      l1 - The first line
      l2 - The second line
      Returns:
      True if the two given lines are same, false otherwise
    • areaOfTriangleGivenLine

      public double areaOfTriangleGivenLine(Line l1, Line l2, Line l3)
      Returns the area of a triangle given three lines.
      Parameters:
      l1 - The first line
      l2 - The second line
      l3 - The third line
      Returns:
      The area of the triangle
    • isThreeLinesSame

      public boolean isThreeLinesSame(Line l1, Line l2, Line l3)
      Returns if the given three lines are same or not
      Parameters:
      l1 - The first line
      l2 - The second line
      l3 - The third line
      Returns:
      True if the given three lines are same, false otherwise
    • intersectionPoint

      public Point intersectionPoint(Line l1, Line l2)
      Returns the intersection point of two lines.
      Parameters:
      l1 - The first line
      l2 - The second line
      Returns:
      The intersection point of the two lines
    • isParallel

      public boolean isParallel(Line l1, Line l2)
      Returns if the two given lines are parallel or not
      Parameters:
      l1 - The first line
      l2 - The second line
      Returns:
      True if the two given lines are parallel, false otherwise
    • isPerpendicular

      public boolean isPerpendicular(Line l1, Line l2)
      Returns if the two given lines are perpendicular or not
      Parameters:
      l1 - The first line
      l2 - The second line
      Returns:
      True if the two given lines are perpendicular, false otherwise
    • slopeOfLine

      public double slopeOfLine(Line l)
      Returns the slope of a line.
      Parameters:
      l - The line
      Returns:
      The slope of the line
    • distanceBetweenTwoParallelLines

      public double distanceBetweenTwoParallelLines(Line l1, Line l2)
      Returns the distance between two parallel lines.
      Parameters:
      l1 - The first line
      l2 - The second line
      Returns:
      The distance between the two parallel lines
    • perpendicularDistanceFromAPoint

      public double perpendicularDistanceFromAPoint(Line l, Point p)
      Returns the perpendicular distance of a line form a point.
      Parameters:
      l - The line
      p - The point
      Returns:
      The perpendicular distance of the line form the point
    • getPerpendicularLine

      public Line getPerpendicularLine(Line l, Point p)
      Returns the perpendicular line of a line passing through a point.
      Parameters:
      l - The line
      p - The point
      Returns:
      The perpendicular line of the line passing through the point
    • getParallelLine

      public Line getParallelLine(Line l, Point p)
      Returns the parallel line of a line passing through a point.
      Parameters:
      l - The line
      p - The point
      Returns:
      The parallel line of the line passing through the point
    • getLineFromIntersectingPoint

      public Line getLineFromIntersectingPoint(Line l1, Line l2, Point p)
      Returns the line passing through the intersection point of two lines.
      Parameters:
      l1 - The first line
      l2 - The second line
      p - the p
      Returns:
      The line passing through the intersection point of the two lines
    • areaOfQuadrilateralUsingLine

      public double areaOfQuadrilateralUsingLine(Line l1, Line l2, Line l3, Line l4)
      Returns the area of a quadrilateral using four lines inputted in anticlockwise order.
      Parameters:
      l1 - The first line
      l2 - The second line
      l3 - The third line
      l4 - The fourth line
      Returns:
      The area of the quadrilateral
    • areaOfConvexPolygon

      public double areaOfConvexPolygon(Point[] points)
      Returns the area of a convex polygon using points inputted in anticlockwise order.
      Parameters:
      points - The points of the convex polygon
      Returns:
      The area of the convex polygon
    • isPointInPolygon

      public boolean isPointInPolygon(Point[] points, Point p)
      Returns if the point is inside the polygon or not.
      Parameters:
      points - The points of the polygon
      p - The point
      Returns:
      True if the point is inside the polygon, false otherwise
    • getLineFromTwoPoints

      public Line getLineFromTwoPoints(Point p1, Point p2)
      Returns the line passing through two points.
      Parameters:
      p1 - The first point
      p2 - The second point
      Returns:
      The line passing through the two points