Merge pull request #26 from tomfisher/master

Fix the wrong path calculation of Arc with small angle
This commit is contained in:
Michael Bayne
2015-02-04 11:25:59 -08:00
43 changed files with 125 additions and 43 deletions
+1 -1
View File
@@ -283,7 +283,7 @@ public abstract class AbstractArc extends RectangularShape implements IArc
k = -k; k = -k;
} }
} else { } else {
arcCount = (int)Math.rint(Math.abs(extent) / 90f); arcCount = MathUtil.iceil(Math.abs(extent) / 90f);
step = Math.toRadians(extent / arcCount); step = Math.toRadians(extent / arcCount);
k = 4f / 3f * (1f - Math.cos(step / 2f)) / Math.sin(step / 2f); k = 4f / 3f * (1f - Math.cos(step / 2f)) / Math.sin(step / 2f);
} }
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Arc extends AbstractArc implements Serializable public class Arc extends AbstractArc implements Serializable
{ {
/** The x-coordinate of this arc's framing rectangle. */ private static final long serialVersionUID = -2351063986218111710L;
/** The x-coordinate of this arc's framing rectangle. */
public double x; public double x;
/** The y-coordinate of this arc's framing rectangle. */ /** The y-coordinate of this arc's framing rectangle. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Box implements IBox, Serializable public class Box implements IBox, Serializable
{ {
/** The unit box. */ private static final long serialVersionUID = 5387466195433177670L;
/** The unit box. */
public static final Box UNIT = new Box(Vector3.UNIT_XYZ.negate(), Vector3.UNIT_XYZ); public static final Box UNIT = new Box(Vector3.UNIT_XYZ.negate(), Vector3.UNIT_XYZ);
/** The zero box. */ /** The zero box. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Circle extends AbstractCircle implements Serializable public class Circle extends AbstractCircle implements Serializable
{ {
/** The x-coordinate of the circle. */ private static final long serialVersionUID = -3344650739420164686L;
/** The x-coordinate of the circle. */
public double x; public double x;
/** The y-coordinate of the circle. */ /** The y-coordinate of the circle. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class CubicCurve extends AbstractCubicCurve implements Serializable public class CubicCurve extends AbstractCubicCurve implements Serializable
{ {
/** The x-coordinate of the start of this curve. */ private static final long serialVersionUID = 1344542230356205271L;
/** The x-coordinate of the start of this curve. */
public double x1; public double x1;
/** The y-coordinate of the start of this curve. */ /** The y-coordinate of the start of this curve. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Dimension extends AbstractDimension implements Serializable public class Dimension extends AbstractDimension implements Serializable
{ {
/** The magnitude in the x-dimension. */ private static final long serialVersionUID = 6057102762997878357L;
/** The magnitude in the x-dimension. */
public double width; public double width;
/** The magnitude in the y-dimension. */ /** The magnitude in the y-dimension. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Ellipse extends AbstractEllipse implements Serializable public class Ellipse extends AbstractEllipse implements Serializable
{ {
/** The x-coordinate of the framing rectangle. */ private static final long serialVersionUID = -2681903285662523175L;
/** The x-coordinate of the framing rectangle. */
public double x; public double x;
/** The y-coordinate of the framing rectangle. */ /** The y-coordinate of the framing rectangle. */
@@ -11,7 +11,9 @@ package pythagoras.d;
*/ */
public class IllegalPathStateException extends RuntimeException public class IllegalPathStateException extends RuntimeException
{ {
public IllegalPathStateException () { private static final long serialVersionUID = -1876236224736636005L;
public IllegalPathStateException () {
} }
public IllegalPathStateException (String s) { public IllegalPathStateException (String s) {
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Line extends AbstractLine implements Serializable public class Line extends AbstractLine implements Serializable
{ {
/** The x-coordinate of the start of this line segment. */ private static final long serialVersionUID = -9086971085479796688L;
/** The x-coordinate of the start of this line segment. */
public double x1; public double x1;
/** The y-coordinate of the start of this line segment. */ /** The y-coordinate of the start of this line segment. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.SingularMatrixException;
*/ */
public class Matrix3 implements IMatrix3, Serializable public class Matrix3 implements IMatrix3, Serializable
{ {
/** the identity matrix. */ private static final long serialVersionUID = -2923052760368784693L;
/** the identity matrix. */
public static final Matrix3 IDENTITY = new Matrix3(); public static final Matrix3 IDENTITY = new Matrix3();
/** The values of the matrix. The names take the form {@code mCOLROW}. */ /** The values of the matrix. The names take the form {@code mCOLROW}. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.SingularMatrixException;
*/ */
public final class Matrix4 implements IMatrix4, Serializable public final class Matrix4 implements IMatrix4, Serializable
{ {
/** The identity matrix. */ private static final long serialVersionUID = 2376107607832772408L;
/** The identity matrix. */
public static final IMatrix4 IDENTITY = new Matrix4(); public static final IMatrix4 IDENTITY = new Matrix4();
/** An empty matrix array. */ /** An empty matrix array. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.Platform;
*/ */
public class Plane implements IPlane, Serializable public class Plane implements IPlane, Serializable
{ {
/** The X/Y plane. */ private static final long serialVersionUID = 5309702666731799041L;
/** The X/Y plane. */
public static final Plane XY_PLANE = new Plane(Vector3.UNIT_Z, 0f); public static final Plane XY_PLANE = new Plane(Vector3.UNIT_Z, 0f);
/** The X/Z plane. */ /** The X/Z plane. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Point extends AbstractPoint implements Serializable public class Point extends AbstractPoint implements Serializable
{ {
/** The x-coordinate of the point. */ private static final long serialVersionUID = 4524700003415412445L;
/** The x-coordinate of the point. */
public double x; public double x;
/** The y-coordinate of the point. */ /** The y-coordinate of the point. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class QuadCurve extends AbstractQuadCurve implements Serializable public class QuadCurve extends AbstractQuadCurve implements Serializable
{ {
/** The x-coordinate of the start of this curve. */ private static final long serialVersionUID = -7816504376651508296L;
/** The x-coordinate of the start of this curve. */
public double x1; public double x1;
/** The y-coordinate of the start of this curve. */ /** The y-coordinate of the start of this curve. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.Platform;
*/ */
public class Quaternion implements IQuaternion, Serializable public class Quaternion implements IQuaternion, Serializable
{ {
/** The identity quaternion. */ private static final long serialVersionUID = -2507768410601557773L;
/** The identity quaternion. */
public static final IQuaternion IDENTITY = new Quaternion(0f, 0f, 0f, 1f); public static final IQuaternion IDENTITY = new Quaternion(0f, 0f, 0f, 1f);
/** The components of the quaternion. */ /** The components of the quaternion. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Rectangle extends AbstractRectangle implements Serializable public class Rectangle extends AbstractRectangle implements Serializable
{ {
/** The x-coordinate of the rectangle's upper left corner. */ private static final long serialVersionUID = 6584214897153526799L;
/** The x-coordinate of the rectangle's upper left corner. */
public double x; public double x;
/** The y-coordinate of the rectangle's upper left corner. */ /** The y-coordinate of the rectangle's upper left corner. */
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class RoundRectangle extends AbstractRoundRectangle implements Serializable public class RoundRectangle extends AbstractRoundRectangle implements Serializable
{ {
/** The x-coordinate of the framing rectangle. */ private static final long serialVersionUID = -8496388509757573705L;
/** The x-coordinate of the framing rectangle. */
public double x; public double x;
/** The y-coordinate of the framing rectangle. */ /** The y-coordinate of the framing rectangle. */
+3 -1
View File
@@ -14,7 +14,9 @@ import pythagoras.util.Platform;
*/ */
public class Vector3 implements IVector3, Serializable public class Vector3 implements IVector3, Serializable
{ {
/** A unit vector in the X+ direction. */ private static final long serialVersionUID = -6374261949619913930L;
/** A unit vector in the X+ direction. */
public static final IVector3 UNIT_X = new Vector3(1f, 0f, 0f); public static final IVector3 UNIT_X = new Vector3(1f, 0f, 0f);
/** A unit vector in the Y+ direction. */ /** A unit vector in the Y+ direction. */
+3 -1
View File
@@ -14,7 +14,9 @@ import pythagoras.util.Platform;
*/ */
public class Vector4 implements IVector4, Serializable public class Vector4 implements IVector4, Serializable
{ {
/** The components of the vector. */ private static final long serialVersionUID = -5007926039614742505L;
/** The components of the vector. */
public double x, y, z, w; public double x, y, z, w;
/** /**
+1 -1
View File
@@ -283,7 +283,7 @@ public abstract class AbstractArc extends RectangularShape implements IArc
k = -k; k = -k;
} }
} else { } else {
arcCount = (int)Math.rint(Math.abs(extent) / 90f); arcCount = MathUtil.iceil(Math.abs(extent) / 90f);
step = FloatMath.toRadians(extent / arcCount); step = FloatMath.toRadians(extent / arcCount);
k = 4f / 3f * (1f - FloatMath.cos(step / 2f)) / FloatMath.sin(step / 2f); k = 4f / 3f * (1f - FloatMath.cos(step / 2f)) / FloatMath.sin(step / 2f);
} }
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Arc extends AbstractArc implements Serializable public class Arc extends AbstractArc implements Serializable
{ {
/** The x-coordinate of this arc's framing rectangle. */ private static final long serialVersionUID = 378120636227888073L;
/** The x-coordinate of this arc's framing rectangle. */
public float x; public float x;
/** The y-coordinate of this arc's framing rectangle. */ /** The y-coordinate of this arc's framing rectangle. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Box implements IBox, Serializable public class Box implements IBox, Serializable
{ {
/** The unit box. */ private static final long serialVersionUID = -367110846212429910L;
/** The unit box. */
public static final Box UNIT = new Box(Vector3.UNIT_XYZ.negate(), Vector3.UNIT_XYZ); public static final Box UNIT = new Box(Vector3.UNIT_XYZ.negate(), Vector3.UNIT_XYZ);
/** The zero box. */ /** The zero box. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Circle extends AbstractCircle implements Serializable public class Circle extends AbstractCircle implements Serializable
{ {
/** The x-coordinate of the circle. */ private static final long serialVersionUID = -4841212861047390886L;
/** The x-coordinate of the circle. */
public float x; public float x;
/** The y-coordinate of the circle. */ /** The y-coordinate of the circle. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class CubicCurve extends AbstractCubicCurve implements Serializable public class CubicCurve extends AbstractCubicCurve implements Serializable
{ {
/** The x-coordinate of the start of this curve. */ private static final long serialVersionUID = -3306427309314031213L;
/** The x-coordinate of the start of this curve. */
public float x1; public float x1;
/** The y-coordinate of the start of this curve. */ /** The y-coordinate of the start of this curve. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Dimension extends AbstractDimension implements Serializable public class Dimension extends AbstractDimension implements Serializable
{ {
/** The magnitude in the x-dimension. */ private static final long serialVersionUID = 3237732020142181995L;
/** The magnitude in the x-dimension. */
public float width; public float width;
/** The magnitude in the y-dimension. */ /** The magnitude in the y-dimension. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Ellipse extends AbstractEllipse implements Serializable public class Ellipse extends AbstractEllipse implements Serializable
{ {
/** The x-coordinate of the framing rectangle. */ private static final long serialVersionUID = -1205529661373764424L;
/** The x-coordinate of the framing rectangle. */
public float x; public float x;
/** The y-coordinate of the framing rectangle. */ /** The y-coordinate of the framing rectangle. */
@@ -11,7 +11,9 @@ package pythagoras.f;
*/ */
public class IllegalPathStateException extends RuntimeException public class IllegalPathStateException extends RuntimeException
{ {
public IllegalPathStateException () { private static final long serialVersionUID = 5494939619370624441L;
public IllegalPathStateException () {
} }
public IllegalPathStateException (String s) { public IllegalPathStateException (String s) {
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Line extends AbstractLine implements Serializable public class Line extends AbstractLine implements Serializable
{ {
/** The x-coordinate of the start of this line segment. */ private static final long serialVersionUID = -1771222822536940013L;
/** The x-coordinate of the start of this line segment. */
public float x1; public float x1;
/** The y-coordinate of the start of this line segment. */ /** The y-coordinate of the start of this line segment. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.SingularMatrixException;
*/ */
public class Matrix3 implements IMatrix3, Serializable public class Matrix3 implements IMatrix3, Serializable
{ {
/** the identity matrix. */ private static final long serialVersionUID = 2090355290484132872L;
/** the identity matrix. */
public static final Matrix3 IDENTITY = new Matrix3(); public static final Matrix3 IDENTITY = new Matrix3();
/** The values of the matrix. The names take the form {@code mCOLROW}. */ /** The values of the matrix. The names take the form {@code mCOLROW}. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.SingularMatrixException;
*/ */
public final class Matrix4 implements IMatrix4, Serializable public final class Matrix4 implements IMatrix4, Serializable
{ {
/** The identity matrix. */ private static final long serialVersionUID = -4239146234415362557L;
/** The identity matrix. */
public static final IMatrix4 IDENTITY = new Matrix4(); public static final IMatrix4 IDENTITY = new Matrix4();
/** An empty matrix array. */ /** An empty matrix array. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.Platform;
*/ */
public class Plane implements IPlane, Serializable public class Plane implements IPlane, Serializable
{ {
/** The X/Y plane. */ private static final long serialVersionUID = -1683127117567129189L;
/** The X/Y plane. */
public static final Plane XY_PLANE = new Plane(Vector3.UNIT_Z, 0f); public static final Plane XY_PLANE = new Plane(Vector3.UNIT_Z, 0f);
/** The X/Z plane. */ /** The X/Z plane. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Point extends AbstractPoint implements Serializable public class Point extends AbstractPoint implements Serializable
{ {
/** The x-coordinate of the point. */ private static final long serialVersionUID = -2666598890366249427L;
/** The x-coordinate of the point. */
public float x; public float x;
/** The y-coordinate of the point. */ /** The y-coordinate of the point. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class QuadCurve extends AbstractQuadCurve implements Serializable public class QuadCurve extends AbstractQuadCurve implements Serializable
{ {
/** The x-coordinate of the start of this curve. */ private static final long serialVersionUID = -6760122161413212105L;
/** The x-coordinate of the start of this curve. */
public float x1; public float x1;
/** The y-coordinate of the start of this curve. */ /** The y-coordinate of the start of this curve. */
+3 -1
View File
@@ -15,7 +15,9 @@ import pythagoras.util.Platform;
*/ */
public class Quaternion implements IQuaternion, Serializable public class Quaternion implements IQuaternion, Serializable
{ {
/** The identity quaternion. */ private static final long serialVersionUID = 6152317379736947895L;
/** The identity quaternion. */
public static final IQuaternion IDENTITY = new Quaternion(0f, 0f, 0f, 1f); public static final IQuaternion IDENTITY = new Quaternion(0f, 0f, 0f, 1f);
/** The components of the quaternion. */ /** The components of the quaternion. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Rectangle extends AbstractRectangle implements Serializable public class Rectangle extends AbstractRectangle implements Serializable
{ {
/** The x-coordinate of the rectangle's upper left corner. */ private static final long serialVersionUID = -803067517133475390L;
/** The x-coordinate of the rectangle's upper left corner. */
public float x; public float x;
/** The y-coordinate of the rectangle's upper left corner. */ /** The y-coordinate of the rectangle's upper left corner. */
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class RoundRectangle extends AbstractRoundRectangle implements Serializable public class RoundRectangle extends AbstractRoundRectangle implements Serializable
{ {
/** The x-coordinate of the framing rectangle. */ private static final long serialVersionUID = 5850741513376725608L;
/** The x-coordinate of the framing rectangle. */
public float x; public float x;
/** The y-coordinate of the framing rectangle. */ /** The y-coordinate of the framing rectangle. */
+3 -1
View File
@@ -14,7 +14,9 @@ import pythagoras.util.Platform;
*/ */
public class Vector3 implements IVector3, Serializable public class Vector3 implements IVector3, Serializable
{ {
/** A unit vector in the X+ direction. */ private static final long serialVersionUID = -3884541171214417861L;
/** A unit vector in the X+ direction. */
public static final IVector3 UNIT_X = new Vector3(1f, 0f, 0f); public static final IVector3 UNIT_X = new Vector3(1f, 0f, 0f);
/** A unit vector in the Y+ direction. */ /** A unit vector in the Y+ direction. */
+3 -1
View File
@@ -14,7 +14,9 @@ import pythagoras.util.Platform;
*/ */
public class Vector4 implements IVector4, Serializable public class Vector4 implements IVector4, Serializable
{ {
/** The components of the vector. */ private static final long serialVersionUID = -775706366125314150L;
/** The components of the vector. */
public float x, y, z, w; public float x, y, z, w;
/** /**
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Dimension extends AbstractDimension implements Serializable public class Dimension extends AbstractDimension implements Serializable
{ {
/** The magnitude in the x-dimension. */ private static final long serialVersionUID = 5773214044931265346L;
/** The magnitude in the x-dimension. */
public int width; public int width;
/** The magnitude in the y-dimension. */ /** The magnitude in the y-dimension. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Point extends AbstractPoint implements Serializable public class Point extends AbstractPoint implements Serializable
{ {
/** The x-coordinate of the point. */ private static final long serialVersionUID = -6346341779228562585L;
/** The x-coordinate of the point. */
public int x; public int x;
/** The y-coordinate of the point. */ /** The y-coordinate of the point. */
+3 -1
View File
@@ -11,7 +11,9 @@ import java.io.Serializable;
*/ */
public class Rectangle extends AbstractRectangle implements Serializable public class Rectangle extends AbstractRectangle implements Serializable
{ {
/** The x-coordinate of the rectangle's upper left corner. */ private static final long serialVersionUID = -2937911833523020174L;
/** The x-coordinate of the rectangle's upper left corner. */
public int x; public int x;
/** The y-coordinate of the rectangle's upper left corner. */ /** The y-coordinate of the rectangle's upper left corner. */
@@ -10,7 +10,9 @@ package pythagoras.util;
*/ */
public class NoninvertibleTransformException extends RuntimeException public class NoninvertibleTransformException extends RuntimeException
{ {
public NoninvertibleTransformException (String s) { private static final long serialVersionUID = 5208863644264280750L;
public NoninvertibleTransformException (String s) {
super(s); super(s);
} }
} }
@@ -9,7 +9,9 @@ package pythagoras.util;
*/ */
public class SingularMatrixException extends RuntimeException public class SingularMatrixException extends RuntimeException
{ {
/** private static final long serialVersionUID = -4744745375693073952L;
/**
* Creates a new exception. * Creates a new exception.
*/ */
public SingularMatrixException () { public SingularMatrixException () {