Class Scaler

Object
Scaler

public class Scaler extends Object
Scales different types of entities with a ScaleFactor.
Author:
Owen Feehan
  • Method Details

    • scale

      public static Point3i scale(ScaleFactor scalingFactor, Point3i point)
      Scales a point in XY by multiplying each dimension by its corresponding scaling-factor.

      This is an immutable operation.

      Each dimension is rounded to it's nearest value after scaling.

      Parameters:
      scalingFactor - the factor to use for scaling.
      point - the point to scale.
      Returns:
      a newly created point, where the X and Y dimensions have been scaled by the corresponding factor in scalingFactor and the z-dimension value is identical.
    • scaleCeil

      public static Point3i scaleCeil(ScaleFactor scalingFactor, Point3i point)
      Scales a point in XY by multiplying each dimension by its corresponding scaling-factor.

      This is an immutable operation.

      Each dimension is scaled to it's nearest value after scaling.

      Parameters:
      scalingFactor - the factor to use for scaling.
      point - the point to scale.
      Returns:
      a newly created point, where the X and Y dimensions have been scaled by the corresponding factor in scalingFactor and the z-dimension value is identical.
    • scaleMultiplex

      public static int scaleMultiplex(double scalingFactor, int quantity, boolean round)
      Parameters:
      scalingFactor -
      quantity -
      round - if true, scaleRound(double, int) is called, otherwise scaleCeil(double, int).
      Returns:
      the scaled-quantity, rounded or ceiled to the nearest integer.
    • scaleRound

      public static int scaleRound(double scalingFactor, int quantity)
      Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via rounding.

      Refuses to return 0 or any negative value, making 1 the minimum return value.

      Parameters:
      scalingFactor - the scaling-factor.
      quantity - the quantity.
      Returns:
      the scaled-quantity, rounded up or down an integer.
    • scaleCeil

      public static int scaleCeil(double scalingFactor, int quantity)
      Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via ceil.

      Refuses to return 0 or any negative value, making 1 the minimum return value.

      Parameters:
      scalingFactor - the scaling-factor.
      quantity - the quantity.
      Returns:
      the scaled-quantity, rounded up or down an integer.
    • scaleFloor

      public static int scaleFloor(double scalingFactor, int quantity)
      Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via floor.

      Refuses to return 0 or any negative value, making 1 the minimum return value.

      Parameters:
      scalingFactor - the scaling-factor.
      quantity - the quantity.
      Returns:
      the scaled-quantity, rounded up or down an integer.
    • deriveScalingFactor

      public static double deriveScalingFactor(int numerator, int denominator)
      Calculates a scaling-factor (for one dimension) by doing a floating point division of two integers.
      Parameters:
      numerator - to divide by.
      denominator - divider.
      Returns:
      floating-point result of division.