Class MathUtil

java.lang.Object
io.github.tigerbotics7125.tigerlib.util.MathUtil

public class MathUtil extends Object
Math formulas.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    distance(double x1, double x2)
     
    static double
    distance(double x1, double y1, double x2, double y2)
     
    static double
    distance(double x1, double y1, double z1, double x2, double y2, double z2)
     
    static double
    minMaxScaling(double x, double oldMin, double oldMax, double newMin, double newMax)
    Changes the scale of a value from one range to another.
    static boolean
    pnpoly(int numVerts, double[] vertXs, double[] vertYs, double testX, double testY)
    Generic PNPOLY algo for doubles.
    static boolean
    pnpoly(int numVerts, int[] vertXs, int[] vertYs, double testX, double testY)
    Generic PNPOLY algo for ints.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MathUtil

      public MathUtil()
  • Method Details

    • minMaxScaling

      public static double minMaxScaling(double x, double oldMin, double oldMax, double newMin, double newMax)
      Changes the scale of a value from one range to another.
      Parameters:
      x - input
      oldMin - initial lower boundery
      oldMax - initial upper boundery
      newMin - new lower boundery
      newMax - new upper boundery
      Returns:
      x scaled from old to new.
    • pnpoly

      public static boolean pnpoly(int numVerts, double[] vertXs, double[] vertYs, double testX, double testY)
      Generic PNPOLY algo for doubles.
      Parameters:
      numVerts - Number of verticies.
      vertXs - Static array of vertex x points.
      vertYs - Static array of vertex y points.
      testX - Test point X value.
      testY - Test point Y value.
      Returns:
      Wheter the supplied (x, y) coordinate lies within the supplied polygon.
    • pnpoly

      public static boolean pnpoly(int numVerts, int[] vertXs, int[] vertYs, double testX, double testY)
      Generic PNPOLY algo for ints.
      Parameters:
      numVerts - Number of verticies.
      vertXs - Static array of vertex x points.
      vertYs - Static array of vertex y points.
      testX - Test point X value.
      testY - Test point Y value.
      Returns:
      Wheter the supplied (x, y) coordinate lies within the supplied polygon.
    • distance

      public static double distance(double x1, double x2)
      Parameters:
      x1 -
      x2 -
      Returns:
      The Euclidean distance between two points in 1D space.
    • distance

      public static double distance(double x1, double y1, double x2, double y2)
      Parameters:
      x1 -
      y1 -
      x2 -
      y2 -
      Returns:
      The Euclidean distance between two points in 2D space.
    • distance

      public static double distance(double x1, double y1, double z1, double x2, double y2, double z2)
      Parameters:
      x1 -
      y1 -
      z1 -
      x2 -
      y2 -
      z2 -
      Returns:
      The Euclidean distance between two points in 3D space.