Class GeometryUtils

java.lang.Object
icyllis.arc3d.core.GeometryUtils

public class GeometryUtils extends Object
Geometry solvers.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    chopCubicAt(float[] src, int srcOff, float[] dst, int dstOff, float t)
     
    static void
    chopCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, float[] dst, int off)
     
    static void
    chopQuadAt(float[] src, int srcOff, float[] dst, int dstOff, float t)
     
    static void
    chopQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, float[] dst, int off)
     
    static int
    computeConicToQuads(float x0, float y0, float x1, float y1, float x2, float y2, float w1, float[] dst, int off, int level)
    Chop the conic into N quads, stored continuously in dst, where N = 1 invalid input: '<'invalid input: '<' level.
    static int
    computeConicToQuadsLevel(float x0, float y0, float x1, float y1, float x2, float y2, float w1, float tol)
    Return the log2 number of quadratic Bézier curves needed to approximate the conic with a sequence of quadratic Bézier curves.
    static int
    deduplicate_pairs(float[] arr, int off, int count)
    Given an array and count, remove all pair-wise duplicates from the array, keeping the existing sorting, and return the new count
    static void
    eval_cubic_derivative(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, float[] dst, int off)
     
    static void
    evalCubicAt(float[] src, int srcOff, float[] dst, int dstOff, float t)
     
    static void
    evalCubicAt(float[] src, int srcOff, float t, float[] pos, int posOff, float[] tangent, int tangentOff)
     
    static void
    evalCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, float[] dst, int off)
    t must be 0 invalid input: '<'= t invalid input: '<'= 1.0
    static void
    evalCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, float[] pos, int posOff, float[] tangent, int tangentOff)
    t must be 0 invalid input: '<'= t invalid input: '<'= 1.0; tangent vector is not normalized
    static void
    evalQuadAt(float[] src, int srcOff, float[] dst, int dstOff, float t)
     
    static void
    evalQuadAt(float[] src, int srcOff, float t, float[] pos, int posOff, float[] tangent, int tangentOff)
     
    static void
    evalQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, float[] dst, int off)
    t must be 0 invalid input: '<'= t invalid input: '<'= 1.0
    static void
    evalQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, float[] pos, int posOff, float[] tangent, int tangentOff)
    t must be 0 invalid input: '<'= t invalid input: '<'= 1.0; tangent vector is not normalized
    static float
    findCubicCusp(float[] src, int off)
     
    static float
    findCubicCusp(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
    Returns t value of cusp if cubic has one; returns -1 otherwise.
    static int
    findCubicInflectionPoints(float[] src, int srcOff, float[] dst, int dstOff)
     
    static int
    findCubicInflectionPoints(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float[] roots, int off)
    Given a cubic bezier, return 0, 1, or 2 t-values that represent the inflection points.
    static int
    findCubicMaxCurvature(float[] src, int srcOff, float[] dst, int dstOff)
     
    static int
    findCubicMaxCurvature(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float[] roots, int off)
    Returns 1, 2 or 3 t-values.
    static float
    findQuadMaxCurvature(float[] src, int off)
     
    static float
    findQuadMaxCurvature(float x0, float y0, float x1, float y1, float x2, float y2)
    Given 3 points on a quadratic bezier, if the point of maximum curvature exists on the segment, returns the t value for this point along the curve.
    static int
    findQuadRoots(float A, float B, float C, float[] roots, int off)
     
    static int
    findUnitCubicRoots(float A, float B, float C, float D, float[] roots, int off)
     
    static int
    findUnitQuadRoots(float A, float B, float C, float[] roots, int off)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_CONIC_TO_QUADS_LEVEL

      public static final int MAX_CONIC_TO_QUADS_LEVEL
      See Also:
  • Constructor Details

    • GeometryUtils

      protected GeometryUtils()
  • Method Details

    • findQuadRoots

      public static int findQuadRoots(float A, float B, float C, float[] roots, int off)
    • findUnitQuadRoots

      public static int findUnitQuadRoots(float A, float B, float C, float[] roots, int off)
    • findQuadMaxCurvature

      public static float findQuadMaxCurvature(@Size(min=6L) float[] src, int off)
    • findQuadMaxCurvature

      public static float findQuadMaxCurvature(float x0, float y0, float x1, float y1, float x2, float y2)
      Given 3 points on a quadratic bezier, if the point of maximum curvature exists on the segment, returns the t value for this point along the curve. Otherwise it will return a value of 0.
    • evalQuadAt

      public static void evalQuadAt(@Size(min=6L) float[] src, int srcOff, @Size(min=2L) float[] dst, int dstOff, float t)
    • evalQuadAt

      public static void evalQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, @Size(min=2L) float[] dst, int off)
      t must be 0 invalid input: '<'= t invalid input: '<'= 1.0
    • evalQuadAt

      public static void evalQuadAt(@Size(min=6L) float[] src, int srcOff, float t, @Size(min=2L) float[] pos, int posOff, @Size(min=2L) float[] tangent, int tangentOff)
    • evalQuadAt

      public static void evalQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, @Size(min=2L) float[] pos, int posOff, @Size(min=2L) float[] tangent, int tangentOff)
      t must be 0 invalid input: '<'= t invalid input: '<'= 1.0; tangent vector is not normalized
    • chopQuadAt

      public static void chopQuadAt(@Size(min=6L) float[] src, int srcOff, @Size(min=10L) float[] dst, int dstOff, float t)
    • chopQuadAt

      public static void chopQuadAt(float x0, float y0, float x1, float y1, float x2, float y2, float t, @Size(min=10L) float[] dst, int off)
    • findCubicInflectionPoints

      public static int findCubicInflectionPoints(@Size(min=8L) float[] src, int srcOff, @Size(min=2L) float[] dst, int dstOff)
    • findCubicInflectionPoints

      public static int findCubicInflectionPoints(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, @Size(min=2L) float[] roots, int off)
      Given a cubic bezier, return 0, 1, or 2 t-values that represent the inflection points.
    • evalCubicAt

      public static void evalCubicAt(@Size(min=8L) float[] src, int srcOff, @Size(min=2L) float[] dst, int dstOff, float t)
    • evalCubicAt

      public static void evalCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, @Size(min=2L) float[] dst, int off)
      t must be 0 invalid input: '<'= t invalid input: '<'= 1.0
    • evalCubicAt

      public static void evalCubicAt(@Size(min=8L) float[] src, int srcOff, float t, @Size(min=2L) float[] pos, int posOff, @Size(min=2L) float[] tangent, int tangentOff)
    • evalCubicAt

      public static void evalCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, @Size(min=2L) float[] pos, int posOff, @Size(min=2L) float[] tangent, int tangentOff)
      t must be 0 invalid input: '<'= t invalid input: '<'= 1.0; tangent vector is not normalized
    • eval_cubic_derivative

      public static void eval_cubic_derivative(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, @Size(min=2L) float[] dst, int off)
    • chopCubicAt

      public static void chopCubicAt(@Size(min=8L) float[] src, int srcOff, @Size(min=14L) float[] dst, int dstOff, float t)
    • chopCubicAt

      public static void chopCubicAt(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float t, @Size(min=14L) float[] dst, int off)
    • deduplicate_pairs

      public static int deduplicate_pairs(float[] arr, int off, int count)
      Given an array and count, remove all pair-wise duplicates from the array, keeping the existing sorting, and return the new count
    • findUnitCubicRoots

      public static int findUnitCubicRoots(float A, float B, float C, float D, float[] roots, int off)
    • findCubicMaxCurvature

      public static int findCubicMaxCurvature(@Size(min=8L) float[] src, int srcOff, @Size(min=3L) float[] dst, int dstOff)
    • findCubicMaxCurvature

      public static int findCubicMaxCurvature(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, @Size(min=3L) float[] roots, int off)
      Returns 1, 2 or 3 t-values.
    • findCubicCusp

      public static float findCubicCusp(@Size(min=8L) float[] src, int off)
    • findCubicCusp

      public static float findCubicCusp(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
      Returns t value of cusp if cubic has one; returns -1 otherwise.
    • computeConicToQuadsLevel

      public static int computeConicToQuadsLevel(float x0, float y0, float x1, float y1, float x2, float y2, float w1, float tol)
      Return the log2 number of quadratic Bézier curves needed to approximate the conic with a sequence of quadratic Bézier curves. Will be 0 to 5.
    • computeConicToQuads

      public static int computeConicToQuads(float x0, float y0, float x1, float y1, float x2, float y2, float w1, float[] dst, int off, int level)
      Chop the conic into N quads, stored continuously in dst, where N = 1 invalid input: '<'invalid input: '<' level. The amount of storage needed is (4 * N + 2)
      Parameters:
      w1 - conic weight
      level - 0 to 5 (1 to 32 quad curves)
      Returns:
      actual number of quad curves