Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Servlet generates the points for the curve and adds them as JSON to t…
…he response. Need to implement error handling for when processing the file upload fails.
- Loading branch information
Showing
9 changed files
with
306 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.knotrenderer.utiltest; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.junit.Test; | ||
|
||
import com.knotrenderer.model.BezierCurve; | ||
import com.knotrenderer.model.Curve; | ||
import com.knotrenderer.model.LineSegment; | ||
import com.knotrenderer.util.CurveLoader; | ||
|
||
import processing.core.PVector; | ||
|
||
public class RandomTest { | ||
private static final String CURVE_PATH = "D:/Peter/College_Grad_School/Independent_Study_Spring_2016_Cont/Knot-Renderer-Processing/Testing_Files/TJP-C1.curve"; | ||
private static final String CURVE_PATH2 = "D:/Peter/College_Grad_School/Independent_Study_Spring_2016_Cont/Knot-Renderer-Processing/Testing_Files/TJP-C2.curve"; | ||
|
||
private static final Curve CURVE = CurveLoader.loadCurveFromFile(CURVE_PATH); | ||
private static final BezierCurve BEZIER_CURVE = new BezierCurve(CURVE.getKnotPoints()); | ||
|
||
private static final Curve CURVE2 = CurveLoader.loadCurveFromFile(CURVE_PATH2); | ||
private static final BezierCurve BEZIER_CURVE2 = new BezierCurve(CURVE2.getKnotPoints()); | ||
|
||
|
||
private static PVector vector1 = new PVector(0f, 0f, 0f); | ||
private static PVector vector2 = new PVector(0.31f, 0.81f, 1.00f); | ||
private static PVector vector3 = new PVector(-2.1f, -2.7f, 1.90f); | ||
private static PVector vector4 = new PVector(-1.9f, -3.4f, 0.91f); | ||
private static PVector vector5 = new PVector(0.19f, 0.78f, 0.19f); | ||
private static PVector vector6 = new PVector(1.56f, 2.32f, -0.96f); | ||
private static PVector vector7 = new PVector(0f, 0f, 0f); | ||
|
||
private static PVector vector8 = new PVector(0f, 0f, 0f); | ||
private static PVector vector9 = new PVector(0.0305f, 0.0810f, 0.9962f); | ||
private static PVector vector10 = new PVector(-0.2074f, -0.2671f, 1.9030f); | ||
private static PVector vector11 = new PVector(-0.1792f, -0.3402f, 0.9063f); | ||
private static PVector vector12 = new PVector(0.0189f, 0.0782f, 0.0185f); | ||
private static PVector vector13 = new PVector(0.1557f, 0.2329f, -0.9600f); | ||
private static PVector vector14 = new PVector(0f, 0f, 0f); | ||
|
||
|
||
private static ArrayList<PVector> knotPoints = new ArrayList<PVector>(); | ||
static{ | ||
knotPoints.add(vector1); | ||
knotPoints.add(vector2); | ||
knotPoints.add(vector3); | ||
knotPoints.add(vector4); | ||
knotPoints.add(vector5); | ||
knotPoints.add(vector6); | ||
knotPoints.add(vector7); | ||
} | ||
|
||
private static ArrayList<PVector> knotPoints_2 = new ArrayList<PVector>(); | ||
static{ | ||
knotPoints_2.add(vector8); | ||
knotPoints_2.add(vector9); | ||
knotPoints_2.add(vector10); | ||
knotPoints_2.add(vector11); | ||
knotPoints_2.add(vector12); | ||
knotPoints_2.add(vector13); | ||
knotPoints_2.add(vector14); | ||
} | ||
|
||
@Test | ||
public void testAll() | ||
{ | ||
System.out.println("Curve 1:"); | ||
testOne_A(); | ||
testOne_B(); | ||
System.out.println("Curve 2:"); | ||
testTwo_A(); | ||
testTwo_B(); | ||
} | ||
@Test | ||
public void testOne_A() | ||
{ | ||
testCurve(1, BEZIER_CURVE, 0.7031f); | ||
} | ||
|
||
@Test | ||
public void testOne_B() | ||
{ | ||
testCurve(2, BEZIER_CURVE2, 0.7031f); | ||
} | ||
|
||
@Test | ||
public void testTwo_A() | ||
{ | ||
testCurve(1, BEZIER_CURVE, 0.0633f); | ||
} | ||
|
||
@Test | ||
public void testTwo_B() | ||
{ | ||
testCurve(2, BEZIER_CURVE2, 0.0633f); | ||
} | ||
|
||
private void testCurve(int curvePos, BezierCurve curve, double curvePointToEvaluate) | ||
{ | ||
System.out.println("Curve "+ curvePos + " Recursive Value at " + curvePointToEvaluate +": " + curve.getCurveValueRecursively(curvePointToEvaluate)); | ||
// System.out.println("Curve "+ curvePos + " Summation Value at " + curvePointToEvaluate +": " + curve.getCurveValueFromSummationExpansion(curvePointToEvaluate)); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.