Java examples for java.lang:Math Geometry
Extract scaling from AffineTransform Let assume that the AffineTransform is a composite of scales, translates, and rotates.
//package com.java2s; import java.awt.geom.AffineTransform; public class Main { /**// w w w . ja v a2s .c o m * Extract scaling from AffineTransform<br> * Let assume that the AffineTransform is a composite of scales, translates, and rotates. <br> * No independent shear has to be applied and scaling must be uniform along the two axes. * * @param transform * current AffineTransform */ public static double extractScalingFactor(AffineTransform transform) { double scalingFactor = 1.0; if (transform != null) { double sx = transform.getScaleX(); double shx = transform.getShearX(); if (sx != 0 || shx != 0) { scalingFactor = Math.sqrt(sx * sx + shx * shx); } } return scalingFactor; } }