Class Points

java.lang.Object
org.jgrapht.alg.drawing.model.Points

public abstract class Points
extends java.lang.Object
A collection of utilities to assist with point manipulation.
Author:
Dimitrios Michail
  • Constructor Summary

    Constructors 
    Constructor Description
    Points()  
  • Method Summary

    Modifier and Type Method Description
    static Point2D add​(Point2D a, Point2D b)
    Add 2-dimensional vectors
    static boolean equals​(Point2D p1, Point2D p2)
    Compare two points for equality using tolerance 1e-9.
    static double length​(Point2D v)
    Compute the length of a vector.
    static Point2D negate​(Point2D a)
    Given a vector $a$ compute $-a$.
    static Point2D scalarMultiply​(Point2D a, double scalar)
    Multiply a vector with a scalar.
    static <S> Point2D scalarMultiply​(Point2D a, S scalar, java.util.function.BiFunction<java.lang.Double,​S,​java.lang.Double> mult)
    Multiply a vector with a scalar.
    static Point2D subtract​(Point2D a, Point2D b)
    Subtract 2-dimensional vectors

    Methods inherited from class java.lang.Object

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

  • Method Details

    • length

      public static double length​(Point2D v)
      Compute the length of a vector. The length of vector $(x,y)$ is given by $\sqrt{x^2+y^2}$.
      Parameters:
      v - the vector
      Returns:
      the length of a vector
    • add

      public static Point2D add​(Point2D a, Point2D b)
      Add 2-dimensional vectors
      Parameters:
      a - the first vector
      b - the second vector
      Returns:
      the vector $a+b$
    • subtract

      public static Point2D subtract​(Point2D a, Point2D b)
      Subtract 2-dimensional vectors
      Parameters:
      a - the first vector
      b - the second vector
      Returns:
      the vector $a-b$
    • negate

      public static Point2D negate​(Point2D a)
      Given a vector $a$ compute $-a$.
      Parameters:
      a - the vector
      Returns:
      the vector $-a$
    • scalarMultiply

      public static Point2D scalarMultiply​(Point2D a, double scalar)
      Multiply a vector with a scalar.
      Parameters:
      a - the vector
      scalar - the scalar
      Returns:
      the result of scalar multiplication
    • scalarMultiply

      public static <S> Point2D scalarMultiply​(Point2D a, S scalar, java.util.function.BiFunction<java.lang.Double,​S,​java.lang.Double> mult)
      Multiply a vector with a scalar.
      Type Parameters:
      S - the scalar type
      Parameters:
      a - the vector
      scalar - the scalar
      mult - the multiplication operator
      Returns:
      the result of scalar multiplication
    • equals

      public static boolean equals​(Point2D p1, Point2D p2)
      Compare two points for equality using tolerance 1e-9.
      Parameters:
      p1 - the first point
      p2 - the second point
      Returns:
      whether the two points are equal or not