use of javax.vecmath.Point3d in project JMRI by JMRI.
the class PositionFile method positionFromElement.
public Point3d positionFromElement(Element position) {
Element e;
e = position.getChild("x");
float x = Float.parseFloat(e.getText());
e = position.getChild("y");
float y = Float.parseFloat(e.getText());
e = position.getChild("z");
float z = Float.parseFloat(e.getText());
return new Point3d(x, y, z);
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class InitialAlgorithmTest method testCalc3_not1.
@Test
public void testCalc3_not1() {
Reading r = new Reading("21", new double[] { 0., 13. / vs, 13. / vs, 13. / vs });
Point3d s2 = new Point3d(-3.0f, 4.0f, 0.0f);
Point3d s3 = new Point3d(-3.0f, -4.0f, 0.0f);
Point3d s4 = new Point3d(5.0f, 0.0f, 0.0f);
Calculator c = new InitialAlgorithm(s2, s3, s4, vs);
Measurement m = c.convert(r, new Point3d(1.f, 1.f, 10.f));
Assert.assertEquals("ID ok", "21", m.getID());
Assert.assertEquals("x close", true, Math.abs(m.x - 0.) < 0.001);
Assert.assertEquals("y close", true, Math.abs(m.y - 0.) < 0.001);
Assert.assertEquals("z close", true, Math.abs(m.z - 12.) < 0.001);
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class InitialAlgorithmTest method testCalc3_not2.
@Test
public void testCalc3_not2() {
Reading r = new Reading("21", new double[] { 0., 7. / vs, 13. / vs, 13. / vs });
Point3d s1 = new Point3d(0.0f, 0.0f, 5.0f);
Point3d s3 = new Point3d(-3.0f, -4.0f, 0.0f);
Point3d s4 = new Point3d(5.0f, 0.0f, 0.0f);
Calculator c = new InitialAlgorithm(s1, s3, s4, vs);
Measurement m = c.convert(r, new Point3d(1.f, 1.f, 10.f));
Assert.assertEquals("ID ok", "21", m.getID());
Assert.assertEquals("x close", true, Math.abs(m.x - 0.) < 0.001);
Assert.assertEquals("y close", true, Math.abs(m.y - 0.) < 0.001);
Assert.assertEquals("z close", true, Math.abs(m.z - 12.) < 0.001);
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class InitialAlgorithmTest method testCalc3_not4.
@Test
public void testCalc3_not4() {
Reading r = new Reading("21", new double[] { 0., 7. / vs, 13. / vs, 13. / vs });
Point3d s1 = new Point3d(0.0f, 0.0f, 5.0f);
Point3d s2 = new Point3d(-3.0f, 4.0f, 0.0f);
Point3d s3 = new Point3d(-3.0f, -4.0f, 0.0f);
Calculator c = new InitialAlgorithm(s1, s2, s3, vs);
Measurement m = c.convert(r, new Point3d(1.f, 1.f, 10.f));
Assert.assertEquals("ID ok", "21", m.getID());
Assert.assertEquals("x close", true, Math.abs(m.x - 0.) < 0.001);
Assert.assertEquals("y close", true, Math.abs(m.y - 0.) < 0.001);
Assert.assertEquals("z close", true, Math.abs(m.z - 12.) < 0.001);
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class Ash1_1AlgorithmTest method testCalc4_not1.
@Test
// fails for unknown reasons
@Ignore
public void testCalc4_not1() {
Point3d s2 = new Point3d(-3.0f, 4.0f, 9.0f);
Point3d s3 = new Point3d(-3.0f, -4.0f, 10.0f);
Point3d s4 = new Point3d(5.0f, 0.0f, 11.0f);
Point3d s5 = new Point3d(0.0f, 13.0f, 9.0f);
Point3d[] s = new Point3d[] { s2, s3, s4, s5 };
Reading r = new Reading("21", new double[] { time(s2), time(s3), time(s4), time(s5) });
Calculator c = new Ash1_1Algorithm(s, vs);
Measurement m = c.convert(r, new Point3d(1.f, 1.f, 10.f));
Assert.assertEquals("ID ok", "21", m.getID());
Assert.assertEquals("x close", true, Math.abs(m.x - 3.) < 0.001);
Assert.assertEquals("y close", true, Math.abs(m.y - 2.) < 0.001);
Assert.assertEquals("z close", true, Math.abs(m.z - 1.) < 0.001);
}
Aggregations