Search in sources :

Example 21 with Point3d

use of javax.vecmath.Point3d in project JMRI by JMRI.

the class InitialAlgorithmTest method testCalc3_not3.

@Test
public void testCalc3_not3() {
    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 s4 = new Point3d(5.0f, 0.0f, 0.0f);
    Calculator c = new InitialAlgorithm(s1, s2, 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);
}
Also used : Point3d(javax.vecmath.Point3d) Test(org.junit.Test)

Example 22 with Point3d

use of javax.vecmath.Point3d in project JMRI by JMRI.

the class Ash1_0AlgorithmTest method testCalc4_not2.

@Test
// fails for unknown reasons
@Ignore
public void testCalc4_not2() {
    Reading r = new Reading("21", new double[] { 7. / vs, 13. / vs, 13. / vs, 3. / 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);
    Point3d s4 = new Point3d(5.0f, 0.0f, 0.0f);
    Point3d s5 = new Point3d(0.0f, 0.0f, 15.0f);
    Point3d[] s = new Point3d[] { s1, s3, s4, s5 };
    Calculator c = new Ash1_0Algorithm(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 - 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);
}
Also used : Point3d(javax.vecmath.Point3d) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with Point3d

use of javax.vecmath.Point3d in project JMRI by JMRI.

the class Ash1_1AlgorithmTest method testCalc4_not3.

@Test
// fails for unknown reasons
@Ignore
public void testCalc4_not3() {
    Point3d s1 = new Point3d(10.0f, 0.0f, 12.0f);
    Point3d s2 = new Point3d(-3.0f, 4.0f, 9.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[] { s1, s2, s4, s5 };
    Reading r = new Reading("21", new double[] { time(s1), time(s2), 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);
}
Also used : Point3d(javax.vecmath.Point3d) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with Point3d

use of javax.vecmath.Point3d in project JMRI by JMRI.

the class RpsTrackingFrameTest method testShow.

@Test
public void testShow() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    new Engine() {

        void reset() {
            _instance = null;
        }
    }.reset();
    Engine.instance().setMaxReceiverNumber(2);
    Engine.instance().setReceiver(1, new Receiver(new Point3d(12., 12., 0.)));
    Engine.instance().setReceiver(2, new Receiver(new Point3d(12., 12., 0.)));
    RpsTrackingFrame f = new RpsTrackingFrame("Test RPS Tracking");
    f.initComponents();
    f.setVisible(true);
    // use local access
    RpsTrackingPanel p = f.panel;
    Reading loco = new Reading("21", null);
    Measurement m = new Measurement(loco, 0.0, 0.0, 0.0, 0.133, 5, "source");
    p.notify(m);
    loco = new Reading("21", null);
    m = new Measurement(loco, 5., 5., 0.0, 0.133, 5, "source");
    p.notify(m);
    loco = new Reading("21", null);
    m = new Measurement(loco, 0., 5., 0.0, 0.133, 5, "source");
    p.notify(m);
    loco = new Reading("21", null);
    m = new Measurement(loco, 5., 0., 0.0, 0.133, 5, "source");
    p.notify(m);
    Assert.assertNotNull("found frame", f);
    f.dispose();
}
Also used : Measurement(jmri.jmrix.rps.Measurement) Reading(jmri.jmrix.rps.Reading) Point3d(javax.vecmath.Point3d) Receiver(jmri.jmrix.rps.Receiver) Engine(jmri.jmrix.rps.Engine) Test(org.junit.Test)

Example 25 with Point3d

use of javax.vecmath.Point3d in project JMRI by JMRI.

the class PositionFileTest method testPointElement.

public void testPointElement() {
    PositionFile f = new PositionFile();
    Point3d in = new Point3d(-1.0f, -2.0f, -3.0f);
    Element e = f.positionElement(in);
    Point3d out = f.positionFromElement(e);
    checkPoint3d(in, out);
}
Also used : Point3d(javax.vecmath.Point3d) Element(org.jdom2.Element)

Aggregations

Point3d (javax.vecmath.Point3d)33 Test (org.junit.Test)16 Ignore (org.junit.Ignore)8 Reading (jmri.jmrix.rps.Reading)4 Receiver (jmri.jmrix.rps.Receiver)4 File (java.io.File)3 Measurement (jmri.jmrix.rps.Measurement)3 Engine (jmri.jmrix.rps.Engine)2 PositionFile (jmri.jmrix.rps.PositionFile)2 Region (jmri.jmrix.rps.Region)2 Element (org.jdom2.Element)2 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 Shape (java.awt.Shape)1 Stroke (java.awt.Stroke)1 AffineTransform (java.awt.geom.AffineTransform)1 BoxLayout (javax.swing.BoxLayout)1 JmriJFrame (jmri.util.JmriJFrame)1