Examples of IPoint


Examples of net.algart.math.IPoint

                }
            }
            Matrix<DoubleArray> cyclic = matrix.subMatr(submatrixPos, submatrixDim,
                Matrix.ContinuationMode.CYCLIC);

            IPoint from = IPoint.valueOf(cyclic.subMatrixFrom());
            IPoint to = IPoint.valueOf(cyclic.subMatrixTo());
            Matrix<DoubleArray> pseudoCyclic = matrix.subMatrix(from.coordinates(), to.coordinates(),
                Matrix.ContinuationMode.PSEUDO_CYCLIC);
            System.out.println(testCount + ": testing " + from + ".." + to
                + " inside " + JArrays.toString(matrix.dimensions(), "x", 100));
            for (int shiftIndex = 0; shiftIndex < 1000; shiftIndex++) {
                boolean showResults = shiftIndex < 10;
                long[] shift = new long[cyclic.dimCount()];
                for (int k = 0; k < shift.length; k++) {
                    shift[k] = cyclic.size() == 0 ? rnd.nextInt(10) :
                        showResults && k == shift.length - 1 ?
                            (cyclic.dim(k) + shiftIndex - 1) % cyclic.dim(k) :
                            Math.round(rnd.nextDouble() * (cyclic.dim(k) - 1));
                }
                IPoint p = IPoint.valueOf(shift);
                IPoint shifted = from.add(p);
                long cyclicIndex = matrix.cyclicIndex(shifted.coordinates());
                long pseudoCyclicIndex = matrix.pseudoCyclicIndex(shifted.coordinates());
                long oneDimensional = shifted.toOneDimensional(matrix.dimensions(), true);
                if (pseudoCyclicIndex != oneDimensional)
                    throw new AssertionError("Bug A detected: pseudo-cyclic index calculated differently "
                        + "in Matrix and IPoint: " + pseudoCyclicIndex + " and " + oneDimensional);
                long rPseudoCyclicIndex = hugePseudoCyclicIndex(matrix.dimensions(), shifted.coordinates());
                if (pseudoCyclicIndex != rPseudoCyclicIndex)
                    throw new AssertionError("Bug B detected: pseudo-cyclic index calculated incorrectly: "
                        + pseudoCyclicIndex + " instead of " + rPseudoCyclicIndex);
                if (cyclic.size() == 0) {
                    continue; // cannot test internal indexes
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testConstructor() {
    IPoint pt1   = ShapeFactory.createPoint(1, 1);
    IPoint pt2   = ShapeFactory.createPoint(2, 2);
    IPolyline pol = ShapeFactory.createPolyline(pt1, pt2);

    pol = ShapeFactory.createPolyline(pt1, pt2);
    assertEquals(pt1, pol.getPtAt(0));
    assertEquals(pt2, pol.getPtAt(-1));
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

//  }


  @Test
  public void testConstructor() {
    IPoint pt1   = ShapeFactory.createPoint(1, 1);
    IPoint pt2   = ShapeFactory.createPoint(2, 2);
    IPolygon pol = ShapeFactory.createPolygon(pt1, pt2);

    pol = ShapeFactory.createPolygon(pt1, pt2);
    assertEquals(pt1, pol.getPtAt(0));
    assertEquals(pt2, pol.getPtAt(-1));
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

import org.junit.Test;

public class TestLPoint {
  @Test
  public void testLPoint() {
    IPoint pt = ShapeFactory.createPoint(1.,-200.);

    assertEquals(ShapeFactory.createPoint(), ShapeFactory.createPoint(0.,0.));
    assertEquals(pt.getX(), 1., 0.1);
    assertEquals(pt.getY(), -200., 0.1);

    pt = ShapeFactory.createPoint((IPoint)null);
    assertEquals(pt.getX(), 0., 0.1);
    assertEquals(pt.getY(), 0., 0.1);

    pt = ShapeFactory.createPoint(ShapeFactory.createPoint(-1.34, Double.POSITIVE_INFINITY));
    assertEquals(pt.getX(), -1.34, 0.1);
    assertEquals(pt.getY(), Double.POSITIVE_INFINITY, 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testRotatePoint() {
    IPoint pt = ShapeFactory.createPoint();

    assertNull(pt.rotatePoint( null, 0));
    assertNull(pt.rotatePoint(null, 0));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.NaN));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.NEGATIVE_INFINITY));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.POSITIVE_INFINITY));

    assertEquals(ShapeFactory.createPoint(0,1),  ShapeFactory.createPoint(1,0).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,1).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(-1,0).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(1,0),  ShapeFactory.createPoint(0,-1).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint



  @Test
  public void testCentralSymmetry() {
    IPoint pt = ShapeFactory.createPoint();
    assertNull(pt.centralSymmetry(null));
    assertEquals(ShapeFactory.createPoint(-1,0),  ShapeFactory.createPoint(1,0).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(0,-1),  ShapeFactory.createPoint(0,1).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(1,0),  ShapeFactory.createPoint(-1,0).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(0,1),  ShapeFactory.createPoint(0,-1).centralSymmetry(pt));
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testComputeAngle() {
    IPoint pt1 = ShapeFactory.createPoint();

    assertEquals(Double.NaN, pt1.computeAngle(null), 0.1);
    assertEquals(0., pt1.computeAngle(ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(Math.PI, pt1.computeAngle(ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(0,-1)), 0.1);

    pt1.setPoint(1, 1);
    assertEquals(0., pt1.computeAngle(ShapeFactory.createPoint(2,1)), 0.1);
    assertEquals(Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(1,2)), 0.1);
    assertEquals(Math.PI, pt1.computeAngle(ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(1,0)), 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testComputeRotationAngle() {
    IPoint pt1 = ShapeFactory.createPoint();

    assertEquals(Double.NaN, pt1.computeRotationAngle(null, null), 0.1);
    assertEquals(Double.NaN, pt1.computeRotationAngle(ShapeFactory.createPoint(), null), 0.1);
    assertEquals(Double.NaN, pt1.computeRotationAngle(null, ShapeFactory.createPoint()), 0.1);

    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(0,-1)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(-1,0))), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(0,-1)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(0,-1))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(1,0)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,-1)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(1,0))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,1)), 0.1);

    assertEquals(-3.*Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(0,1))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(-1,0)), 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testTranslate() {
    IPoint pt1 = ShapeFactory.createPoint(2., 1.);
    IPoint pt2 = ShapeFactory.createPoint(2., 1.);

    pt1.translate(Double.NaN, Double.NaN);
    assertEquals(pt1, pt2);
    pt1.translate(Double.NaN, 2.);
    assertEquals(pt1, pt2);
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testHorizontalSymmetry() {
    IPoint pt = ShapeFactory.createPoint(10., 10.);

    assertNull(pt.horizontalSymmetry(null));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(Double.NaN, 1.)));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(1., Double.NaN)));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(Double.POSITIVE_INFINITY, 1.)));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(1., Double.POSITIVE_INFINITY)));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(Double.NEGATIVE_INFINITY, 1.)));
    assertNull(pt.horizontalSymmetry(ShapeFactory.createPoint(1., Double.NEGATIVE_INFINITY)));
    assertEquals(pt.horizontalSymmetry(ShapeFactory.createPoint(0.,0.)), ShapeFactory.createPoint(-10., 10.));
    assertEquals(pt.horizontalSymmetry(ShapeFactory.createPoint(0.,18780.)), ShapeFactory.createPoint(-10., 10.));
    assertEquals(ShapeFactory.createPoint(-10., 10.).horizontalSymmetry(ShapeFactory.createPoint(0.,18780.)), pt);
    assertEquals(ShapeFactory.createPoint(0.,0.).horizontalSymmetry(ShapeFactory.createPoint(0.,0.)), ShapeFactory.createPoint(0., 0.));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.