Package mathvoyage

Class vmath.geometry

java.lang.Object
mathvoyage.vmath.geometry
Enclosing class:
vmath

public static class vmath.geometry extends Object
Contains functions to calculate coordinate geometric operations.
Author:
Tahsin Islam
  • Constructor Details

    • geometry

      public geometry()
  • Method Details

    • distance

      public static double distance(Point p1, Point p2, DistanceType c)
      Returns the distance between two points.
      Parameters:
      p1 - The first point
      p2 - The second point
      c - The type of distance to return
      Returns:
      The distance between the two points
    • slope

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

      public static Point midpoint(Point p1, Point p2)
      Returns the midpoint of given two points.
      Parameters:
      p1 - The first point
      p2 - The second point
      Returns:
      The midpoint
    • centroid

      public static Point centroid(Point p1, Point p2, Point p3)
      Returns the centroid of given three points.
      Parameters:
      p1 - The first point
      p2 - The second point
      p3 - The third point
      Returns:
      The centroid
    • areaOfTriangle

      public static double areaOfTriangle(Point p1, Point p2, Point p3)
      Returns the area of a triangle given three points.
      Parameters:
      p1 - The first point
      p2 - The second point
      p3 - The third point
      Returns:
      The area of the triangle
    • interleaverPoint

      public static Point interleaverPoint(Point p1, Point p2, double m, double n)
      Returns the interleave point of two points.
      Parameters:
      p1 - The first point
      p2 - The second point
      m - the m
      n - the n
      Returns:
      The interleave point
    • externalizerPoint

      public static Point externalizerPoint(Point p1, Point p2, double m, double n)
      Returns the externalizer point of two points.
      Parameters:
      p1 - The first point
      p2 - The second point
      m - the m
      n - the n
      Returns:
      The externalizer point
    • areaOfCircle

      public static double areaOfCircle(Point p1, Point p2)
      Returns the area of a circle given two end points of the radius.
      Parameters:
      p1 - The first point
      p2 - The second point
      Returns:
      The area of the circle
    • circumferenceOfCircle

      public static double circumferenceOfCircle(Point p1, Point p2)
      Returns the circumference of a circle given two end points of the radius.
      Parameters:
      p1 - The first point
      p2 - The second point
      Returns:
      The circumference of the circle
    • isTriangle

      public static boolean isTriangle(Point p1, Point p2, Point p3, triangleType c)
      Returns if the given three points form a triangle is of the given type.
      Parameters:
      p1 - The first point
      p2 - The second point
      p3 - The third point
      c - The type of triangle to check
      Returns:
      true if the triangle is of the given type, else false
    • angleBetweenTwoSlopes

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

      public static boolean isQuadrilateral(Point p1, Point p2, Point p3, Point p4, quadrilateralType c)
      Returns if the given four points form a quadrilateral is of the given type.
      Parameters:
      p1 - The first point
      p2 - The second point
      p3 - The third point
      p4 - The fourth point
      c - The type of quadrilateral to check
      Returns:
      true if the quadrilateral is of the given type, else false
    • isLine

      public static boolean isLine(Line l1, Line l2, lineType c)
      Returns if the given two lines are of the given type.
      Parameters:
      l1 - The first line
      l2 - The second line
      c - The type of line to check
      Returns:
      true if the line is of the given type, else false
    • areThreeLinesSame

      public static boolean areThreeLinesSame(Line l1, Line l2, Line l3)
      Returns if the given three lines are same
      Parameters:
      l1 - The first line
      l2 - The second line
      l3 - The third line
      Returns:
      true if the lines are same, else false
    • intersectionOfTwoLines

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

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

      public static 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 lines
    • perpendicularDistanceFromAPointToALine

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

      public static 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 static 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
    • getLineFromIntersectionPoint

      public static Line getLineFromIntersectionPoint(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
    • areaOfQuadrilateral

      public static double areaOfQuadrilateral(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
    • areaOfQuadrilateral

      public static 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
    • areaOfTriangle

      public static double areaOfTriangle(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
    • areaOfConvexPolygon

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