com.orsoncharts.graphics3d

## Class Utils2D

- java.lang.Object
- - com.orsoncharts.graphics3d.Utils2D

-     public class Utils2D
      extends java.lang.Object

  A collection of utility methods for 2D geometry.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static double` | `area2(java.awt.geom.Point2D a, java.awt.geom.Point2D b, java.awt.geom.Point2D c)` Calculates twice the area of a triangle for points specified in counter-clockwise order (if the points are specified in clockwise order the result will be negative).
    `static double` | `calculateTheta(java.awt.geom.Line2D line)` Returns the angle of rotation (in radians) for the specified line.
    `static java.awt.geom.Point2D` | `centerPoint(java.awt.geom.Point2D pt0, java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2, java.awt.geom.Point2D pt3)` Returns the point in the center of the four supplied points.
    `static java.awt.geom.Line2D` | `createPerpendicularLine(java.awt.geom.Line2D line, double b, double size, java.awt.geom.Point2D opposingPoint)` Creates and returns a line that is perpendicular to the specified line.
    `static java.awt.geom.Line2D` | `createPerpendicularLine(java.awt.geom.Line2D line, java.awt.geom.Point2D pt1, double size, java.awt.geom.Point2D opposingPoint)` Creates and returns a line that is perpendicular to the specified line.
    `static java.awt.Dimension` | `findDimension(java.awt.geom.Point2D[] pts)` Returns the dimensions of the smallest rectangle that could contain the supplied points.
    `static double` | `length(java.awt.geom.Line2D line)` Returns the length of the line.
    `static boolean` | `spans(double value, double bound1, double bound2)` Returns `true` if the specified value is spanned by the two bounds, and `false` otherwise.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### spans

          public static boolean spans(double value,
                                      double bound1,
                                      double bound2)

      Returns `true` if the specified value is spanned by the two bounds, and `false` otherwise.
      Parameters:
        `value` - the value.
        `bound1` - the first boundary.
        `bound2` - the second boundary.
      Returns:
        A boolean.

    - #### area2

          public static double area2(java.awt.geom.Point2D a,
                                     java.awt.geom.Point2D b,
                                     java.awt.geom.Point2D c)

      Calculates twice the area of a triangle for points specified in counter-clockwise order (if the points are specified in clockwise order the result will be negative).
      Parameters:
        `a` - the first point (`null` not permitted).
        `b` - the second point (`null` not permitted).
        `c` - the third point (`null` not permitted).
      Returns:
        The area x 2.

    - #### centerPoint

          public static java.awt.geom.Point2D centerPoint(java.awt.geom.Point2D pt0,
                                                          java.awt.geom.Point2D pt1,
                                                          java.awt.geom.Point2D pt2,
                                                          java.awt.geom.Point2D pt3)

      Returns the point in the center of the four supplied points.
      Parameters:
        `pt0` - point 0 (`null` not permitted).
        `pt1` - point 1 (`null` not permitted).
        `pt2` - point 2 (`null` not permitted).
        `pt3` - point 3 (`null` not permitted).
      Returns:
        The center point (never `null`).

    - #### findDimension

          public static java.awt.Dimension findDimension(java.awt.geom.Point2D[] pts)

      Returns the dimensions of the smallest rectangle that could contain the supplied points.
      Parameters:
        `pts` - an array of points (`null` not permitted).
      Returns:
        The dimensions.

    - #### createPerpendicularLine

          public static java.awt.geom.Line2D createPerpendicularLine(java.awt.geom.Line2D line,
                                                                     double b,
                                                                     double size,
                                                                     java.awt.geom.Point2D opposingPoint)

      Creates and returns a line that is perpendicular to the specified line.
      Parameters:
        `line` - the reference line (`null` not permitted).
        `b` - the base point, expressed as a percentage along the length of the reference line.
        `size` - the size or length of the perpendicular line.
        `opposingPoint` - an opposing point, to define which side of the reference line the perpendicular line will extend (`null` not permitted).
      Returns:
        The perpendicular line.

    - #### createPerpendicularLine

          public static java.awt.geom.Line2D createPerpendicularLine(java.awt.geom.Line2D line,
                                                                     java.awt.geom.Point2D pt1,
                                                                     double size,
                                                                     java.awt.geom.Point2D opposingPoint)

      Creates and returns a line that is perpendicular to the specified line.
      Parameters:
        `line` - the reference line (`null` not permitted).
        `pt1` - a point on the reference line (`null` not permitted).
        `size` - the length of the new line.
        `opposingPoint` - an opposing point, to define which side of the reference line the perpendicular line will extend (`null` not permitted).
      Returns:
        The perpendicular line.

    - #### calculateTheta

          public static double calculateTheta(java.awt.geom.Line2D line)

      Returns the angle of rotation (in radians) for the specified line.
      Parameters:
        `line` - the line (`null` not permitted).
      Returns:
        The angle of rotation (in radians).

    - #### length

          public static double length(java.awt.geom.Line2D line)

      Returns the length of the line.
      Parameters:
        `line` - the line (`null` not permitted).
      Returns:
        The length of the line.