Package org.anchoranalysis.spatial.scale
Class Scaler
Object
org.anchoranalysis.spatial.scale.Scaler
public class Scaler extends Object
Scales different types of entities with a
ScaleFactor.- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description static doublederiveScalingFactor(int numerator, int denominator)Calculates a scaling-factor (for one dimension) by doing a floating point division of two integers.static Point3iscale(ScaleFactor scalingFactor, Point3i point)Scales a point in XY by multiplying each dimension by its corresponding scaling-factor.static intscaleCeil(double scalingFactor, int quantity)Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via ceil.static Point3iscaleCeil(ScaleFactor scalingFactor, Point3i point)Scales a point in XY by multiplying each dimension by its corresponding scaling-factor.static intscaleFloor(double scalingFactor, int quantity)Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via floor.static intscaleMultiplex(double scalingFactor, int quantity, boolean round)static intscaleRound(double scalingFactor, int quantity)Multiplies a quantity (integer) by a scaling-factor, returning it as an integer via rounding.
-
Method Details
-
scale
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
scalingFactorand the z-dimension value is identical.
-
scaleCeil
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
scalingFactorand the z-dimension value is identical.
-
scaleMultiplex
public static int scaleMultiplex(double scalingFactor, int quantity, boolean round)Multiplexes betweenscaleRound(double, int)andscaleCeil(org.anchoranalysis.spatial.scale.ScaleFactor, org.anchoranalysis.spatial.point.Point3i).- Parameters:
scalingFactor-quantity-round- if true,scaleRound(double, int)is called, otherwisescaleCeil(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.
-