Skip to content

Commit

Permalink
final tuning + restored quadlen()
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgesl committed Feb 1, 2018
1 parent 45540fb commit e16efc1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/marlin/pisces/DHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ static double fastQuadLen(final double x0, final double y0,
+ Math.abs(dy1) + Math.abs(dy2);
}

static double quadlen(final double x0, final double y0,
final double x1, final double y1,
final double x2, final double y2)
{
return (linelen(x0, y0, x1, y1)
+ linelen(x1, y1, x2, y2)
+ linelen(x0, y0, x2, y2)) / 2.0d;
}

static double fastCurvelen(final double x0, final double y0,
final double x1, final double y1,
final double x2, final double y2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
public final class DMarlinRenderingEngine extends RenderingEngine
implements MarlinConst
{
// slightly slower ~2% if disabled stroker clipping (skip cap / join + deoptimization ?)
static final boolean DISABLE_2ND_STROKER_CLIPPING = false;

static final boolean DO_TRACE_PATH = false;
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/org/marlin/pisces/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static float linelen(final float x0, final float y0,
{
final float dx = x1 - x0;
final float dy = y1 - y0;
return (float)Math.sqrt(dx * dx + dy * dy);
return (float) Math.sqrt(dx * dx + dy * dy);
}

static float fastQuadLen(final float x0, final float y0,
Expand All @@ -190,6 +190,16 @@ static float fastQuadLen(final float x0, final float y0,
+ Math.abs(dy1) + Math.abs(dy2);
}

static float quadlen(final float x0, final float y0,
final float x1, final float y1,
final float x2, final float y2)
{
return (linelen(x0, y0, x1, y1)
+ linelen(x1, y1, x2, y2)
+ linelen(x0, y0, x2, y2)) / 2.0f;
}


static float fastCurvelen(final float x0, final float y0,
final float x1, final float y1,
final float x2, final float y2,
Expand All @@ -207,15 +217,15 @@ static float fastCurvelen(final float x0, final float y0,
+ Math.abs(dy1) + Math.abs(dy2) + Math.abs(dy3);
}

static double curvelen(final float x0, final float y0,
final float x1, final float y1,
final float x2, final float y2,
final float x3, final float y3)
static float curvelen(final float x0, final float y0,
final float x1, final float y1,
final float x2, final float y2,
final float x3, final float y3)
{
return (linelen(x0, y0, x1, y1)
+ linelen(x1, y1, x2, y2)
+ linelen(x2, y2, x3, y3)
+ linelen(x0, y0, x3, y3)) / 2.0d;
+ linelen(x0, y0, x3, y3)) / 2.0f;
}

// finds values of t where the curve in pts should be subdivided in order
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/marlin/pisces/MarlinRenderingEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
public final class MarlinRenderingEngine extends RenderingEngine
implements MarlinConst
{
// slightly slower ~2% if disabled stroker clipping (skip cap / join + deoptimization ?)
static final boolean DISABLE_2ND_STROKER_CLIPPING = false;

static final boolean DO_TRACE_PATH = false;
Expand Down

0 comments on commit e16efc1

Please sign in to comment.