com.caffeineowl.graphics.bezier.flatnessalgos
Class ConvexHullSubdivCriterion

java.lang.Object
  extended by com.caffeineowl.graphics.bezier.flatnessalgos.ConvexHullFlatnessAlgo
      extended by com.caffeineowl.graphics.bezier.flatnessalgos.ConvexHullSubdivCriterion
All Implemented Interfaces:
CubicFlatnessAlgorithm, CubicSubdivisionCriterion, QuadFlatnessAlgorithm, QuadSubdivisionCriterion

public class ConvexHullSubdivCriterion
extends ConvexHullFlatnessAlgo
implements QuadSubdivisionCriterion, CubicSubdivisionCriterion

Will require the subdivision of a cubic or a quadratic curve any time the cubic's squared flatness (or the quad's ConvexHullFlatnessAlgo.getSquaredFlatness(QuadCurve2D) squared flatness}) is greater than a provided tolerance.

Author:
Adrian Colomitchi (acolomitchi(monkey_tail)gmail.com)

Field Summary
static double minTolerance
          The minimum tolerance allowed by this algo.
protected  double sqTol
          The squared value of the provided tolerance.
 
Constructor Summary
ConvexHullSubdivCriterion()
          Initialises an instance with a default tolerance of 1.0e-5.
ConvexHullSubdivCriterion(double tolerance)
          Initialises the instance with the provided tolerance.
 
Method Summary
 boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
          Returns true whenever the defect is greater than the provided tolerance.
 boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
          Returns true whenever the defect is greater than the provided tolerance.
 
Methods inherited from class com.caffeineowl.graphics.bezier.flatnessalgos.ConvexHullFlatnessAlgo
getFlatness, getFlatness, getSquaredFlatness, getSquaredFlatness, isDegenerationRobust, isSquaredFlatenessPreferred
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minTolerance

public static double minTolerance
The minimum tolerance allowed by this algo. Currently, 1.25*Math.sqrt(Double.MIN_VALUE) (as the algorithm prefers to work with squared distances).


sqTol

protected double sqTol
The squared value of the provided tolerance.

Constructor Detail

ConvexHullSubdivCriterion

public ConvexHullSubdivCriterion()
Initialises an instance with a default tolerance of 1.0e-5.


ConvexHullSubdivCriterion

public ConvexHullSubdivCriterion(double tolerance)
Initialises the instance with the provided tolerance.

Parameters:
tolerance - the tolerance that governs when the the algorithm will require another subdivision. Note that if the
Method Detail

shouldSplit

public final boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
Returns true whenever the defect is greater than the provided tolerance. The method performs the comparison on the squared value.

Specified by:
shouldSplit in interface CubicSubdivisionCriterion

shouldSplit

public final boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
Returns true whenever the defect is greater than the provided tolerance. The method performs the comparison on the squared value.

Specified by:
shouldSplit in interface QuadSubdivisionCriterion