Class MathUtils


  • public class MathUtils
    extends java.lang.Object
    Helper class for basic mathematics.
    • Constructor Summary

      Constructors 
      Constructor Description
      MathUtils()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static float angle​(float x1, float y1, float x2, float y2)
      Calculates angle between point coordinates
      static float angle​(android.graphics.PointF p1, android.graphics.PointF p2)
      Calculates angle between points.
      static float distance​(float x1, float y1, float x2, float y2)
      Calculates distance between two point coordinates.
      static float distance​(android.graphics.PointF p1, android.graphics.PointF p2)
      Calculates distance between two points distance(float, float, float, float)
      static void midpoint​(int x1, int y1, int x2, int y2, android.graphics.PointF point)
      Calculates middle point between two point coordinates.
      void rotate​(android.graphics.PointF p1, android.graphics.PointF p2, float angle)
      Rotates p1 around p2 by angle degrees.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MathUtils

        public MathUtils()
    • Method Detail

      • distance

        public static float distance​(android.graphics.PointF p1,
                                     android.graphics.PointF p2)
        Calculates distance between two points distance(float, float, float, float)
        Parameters:
        p1 - first point.
        p2 - second point.
        Returns:
        distance between points.
      • distance

        public static float distance​(float x1,
                                     float y1,
                                     float x2,
                                     float y2)
        Calculates distance between two point coordinates.
        Parameters:
        x1 - x coordinate of first point.
        y1 - y coordinate of first point.
        x2 - x coordinate of second point.
        y2 - y coordinate of second point.
        Returns:
        distance between two point coordinates.
      • midpoint

        public static void midpoint​(int x1,
                                    int y1,
                                    int x2,
                                    int y2,
                                    android.graphics.PointF point)
        Calculates middle point between two point coordinates.
        Parameters:
        x1 - x coordinate of first point.
        y1 - y coordinate of first point.
        x2 - x coordinate of second point.
        y2 - y coordinate of second point.
        point - middle point.
      • rotate

        public void rotate​(android.graphics.PointF p1,
                           android.graphics.PointF p2,
                           float angle)
        Rotates p1 around p2 by angle degrees.
        Parameters:
        p1 - first point.
        p2 - second point.
        angle - angle.
      • angle

        public static float angle​(android.graphics.PointF p1,
                                  android.graphics.PointF p2)
        Calculates angle between points. Uses angle(float, float, float, float).
        Parameters:
        p1 - first point.
        p2 - second point.
        Returns:
        angle.
      • angle

        public static float angle​(float x1,
                                  float y1,
                                  float x2,
                                  float y2)
        Calculates angle between point coordinates
        Parameters:
        x1 - x coordinate of first point.
        y1 - y coordinate of first point.
        x2 - x coordinate of second point.
        y2 - y coordinate of second point.
        Returns:
        angle.