Module hw06

Class VectorUtil

java.lang.Object
provided.utils.valueGenerator.impl.VectorUtil
All Implemented Interfaces:
IVectorUtil

public class VectorUtil extends Object implements IVectorUtil
Implementation of IVectorUtil
Author:
swong
  • Field Details

    • Singleton

      public static final VectorUtil Singleton
      Singleton instance
  • Constructor Details

    • VectorUtil

      private VectorUtil()
      Private constructor for singleton.
  • Method Details

    • rotate

      public void rotate(Point2D v, double angle)
      Description copied from interface: IVectorUtil
      Utility method to rotate the given vector by the given angle the input vector is mutated. Works with both Points and Point2D.Doubles.
      Specified by:
      rotate in interface IVectorUtil
      Parameters:
      v - A 2-D vector
      angle - Angle to rotate by in radians
    • angleBetween

      public double angleBetween(Point2D v1, Point2D v2)
      Description copied from interface: IVectorUtil
      Utility method to get the signed angle between the two 2-D vectors. Works with both Points and Point2D.Doubles.
      Specified by:
      angleBetween in interface IVectorUtil
      Parameters:
      v1 - vector #1
      v2 - vector #2
      Returns:
      the angle from v1 to v2