Class ScaleFactor

Object
org.anchoranalysis.spatial.scale.ScaleFactor

public final class ScaleFactor
extends Object
What to scale X and Y dimensions by.

This class is immutable.

Author:
Owen Feehan
  • Constructor Summary

    Constructors 
    Constructor Description
    ScaleFactor​(double factor)
    Create with an identical scaling-factor for all dimensions.
    ScaleFactor​(double x, double y)
    Create with specific scaling-factors for each dimension.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(Object o)  
    int hashCode()  
    boolean hasIdenticalXY()
    Is the scale-factor identical in X and Y dimensions?
    ScaleFactor invert()
    Build a new scale factor where each dimension is set to the reciprocal of its current value.
    boolean isNoScale()
    Does the scale-factor involve no scaling at all?
    double minimumDimension()
    Which is the minimum scaling-factor among all dimensions?
    void scale​(Point3d point)
    Multiplies a Point3d by the respective scaling-factor in each X and Y dimensions.
    String toString()  
    double x()
    How much to multiply the existing x-dimension by to create a scaled X-dimension.
    double y()
    How much to multiply the existing y-dimension by to create a scaled Y-dimension.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ScaleFactor

      public ScaleFactor​(double factor)
      Create with an identical scaling-factor for all dimensions.
      Parameters:
      factor - how much to multiply all existing dimensions by to create a scaled dimensions.
    • ScaleFactor

      public ScaleFactor​(double x, double y)
      Create with specific scaling-factors for each dimension.
      Parameters:
      x - how much to multiply the existing x-dimension by to create a scaled x-dimension.
      y - how much to multiply the existing x-dimension by to create a scaled x-dimension.
  • Method Details

    • invert

      public ScaleFactor invert()
      Build a new scale factor where each dimension is set to the reciprocal of its current value.

      This is an immutable operation.

      Returns:
      a newly created ScaleFactor where each component is set to its reciprocal.
    • hasIdenticalXY

      public boolean hasIdenticalXY()
      Is the scale-factor identical in X and Y dimensions?
      Returns:
      true if the scale-factor and Y are identical within 1e-3 precision.
    • isNoScale

      public boolean isNoScale()
      Does the scale-factor involve no scaling at all?
      Returns:
      true if the scale-factor is 1 in all dimensions, false otherwise.
    • minimumDimension

      public double minimumDimension()
      Which is the minimum scaling-factor among all dimensions?
      Returns:
      the minimum scaling-factor
    • scale

      public void scale​(Point3d point)
      Multiplies a Point3d by the respective scaling-factor in each X and Y dimensions.

      No scaling is applied in the Z dimension.

      Parameters:
      point - the point to be scaled.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • x

      public double x()
      How much to multiply the existing x-dimension by to create a scaled X-dimension.
    • y

      public double y()
      How much to multiply the existing y-dimension by to create a scaled Y-dimension.
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object