Examples of FreedomPolygon


Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testRotate() {
        System.out.println("Rotate a polygon");

        FreedomPolygon input = new FreedomPolygon();
        input.append(new FreedomPoint(0, 0));
        input.append(new FreedomPoint(100, 0));
        input.append(new FreedomPoint(100, 50));
        input.append(new FreedomPoint(0, 50));

        int degrees = 90;
        FreedomPolygon expResult = new FreedomPolygon();
        expResult.append(new FreedomPoint(0, 0));
        expResult.append(new FreedomPoint(0, 100));
        expResult.append(new FreedomPoint(-50, 100));
        expResult.append(new FreedomPoint(-50, 0));

        FreedomPolygon result = TopologyUtils.rotate(input, degrees);
        assertEquals(expResult.toString(),
                result.toString());
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testIntersects() {
        System.out.println("Intersects a copy of itself (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(0, 0));
        target.append(new FreedomPoint(100, 0));
        target.append(new FreedomPoint(100, 50));
        target.append(new FreedomPoint(0, 50));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);
        assertEquals(expResult, result);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testIntersects2() {
        System.out.println("Intersects with a rotated copy (90°) of itself (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(0, 0));
        target.append(new FreedomPoint(0, 100));
        target.append(new FreedomPoint(-50, 100));
        target.append(new FreedomPoint(-50, 0));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);
        assertEquals(expResult, result);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testIntersects3() {
        System.out.println("Intersects overlapping polygins with no edge collision (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(50, -25));
        target.append(new FreedomPoint(75, -25));
        target.append(new FreedomPoint(75, 75));
        target.append(new FreedomPoint(50, 75));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);

        //TODO: THIS FAILS MUST BE SOLVED
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testIntersects4() {
        System.out.println("Intersects overlapping polygins with edge collision (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(5, 5));
        target.append(new FreedomPoint(75, -25));
        target.append(new FreedomPoint(75, 75));
        target.append(new FreedomPoint(50, 75));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);
        assertEquals(expResult, result);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

     */
    @Test
    public void testContains() {
        System.out.println("Check if a polygon A contains polygon B");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPoint inside = new FreedomPoint(25, 25);
        FreedomPoint onBorder = new FreedomPoint(25, 0);
        FreedomPoint outside = new FreedomPoint(200, 200);
        assertEquals(true,
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

  void initializeData()
  {
    if (EnvironmentController.getInstance().HasData())
      {
        environment = EnvironmentController.getInstance().getEnvironment();
        FreedomPolygon poly = environment.getShape();
        envPath = DrawingUtils.freedomPolygonToPath(poly);       
        ENVIRONMENT_WIDTH = environment.getWidth();
        ENVIRONMENT_HEIGHT = environment.getHeight();
     
               
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPolygon

        zone.getPojo().setDescription("");

        //check for valid shape
        if (zone.getPojo().getShape() == null) {
            //a default shape
            FreedomPolygon p = new FreedomPolygon();
            p.append(0, 0);
            p.append(200, 0);
            p.append(200, 200);
            p.append(0, 200);
            zone.getPojo().setShape(p);
        }

        //append to list and initilize
        getPojo().getZones().add(zone.getPojo());
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.