Examples of VectorXZ


Examples of org.osm2world.core.math.VectorXZ

    /* snap to som cm precision, seems to reduce geometry exceptions */
    x = Math.round(x * 1000) / 1000.0d;
    y = Math.round(y * 1000) / 1000.0d;

    return new VectorXZ(x, y); // x and z(!) are 2d here
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

            node.getTags().getValue("surface"), Materials.GRITBIN_DEFAULT);
      }
     
      double directionAngle = parseDirection(node.getTags(), PI);
           
      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();
     
      /* draw box */
      target.drawBox(material, getBase(),
          faceVector, height, width, depth);
     
      /* draw lid */
      List<VectorXYZ> vs = new ArrayList<VectorXYZ>();
      vs.add(getBase().addY(height + 0.2));
      vs.add(getBase().add(boardVector.mult(width/2)).add(faceVector.mult(depth/2)).addY(height));
      vs.add(getBase().add(boardVector.mult(-width/2)).add(faceVector.mult(depth/2)).addY(height));
      vs.add(getBase().add(boardVector.mult(-width/2)).add(faceVector.mult(-depth/2)).addY(height));
      vs.add(getBase().add(boardVector.mult(width/2)).add(faceVector.mult(-depth/2)).addY(height));
      vs.add(getBase().add(boardVector.mult(width/2)).add(faceVector.mult(depth/2)).addY(height));
     
      target.drawTriangleFan(material.brighter(), vs, null);
     
    }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

    double lon = toRadians(lonDeg);
   
    double x = GLOBE_RADIUS * cos(lat) * sin(lon - origin.lon);
    double y = GLOBE_RADIUS * (cos(origin.lat) * sin(lat) - sin(origin.lat) * cos(lat) * cos(lon - origin.lon));
   
    return new VectorXZ(x, y);
   
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

    for (VectorXZ v1 : anyVectorXZ()) {
      for (VectorXZ v2 : anyVectorXZ()) {
     
        if (!v1.equals(v2) && !v2.equals(NULL_VECTOR)) {
         
          VectorXZ l1 = v1;
          VectorXZ l2 = v1.add(v2);
          VectorXZ pR = v1.add(v2.rightNormal());
          VectorXZ pL = v1.subtract(v2.rightNormal());
         
          assertTrue(pR + " should be right of " + l1 + "-" + "l2",
              isRightOf(pR, l1, l2));
          assertFalse(pL + " should not be right of " + l1 + "-" + "l2",
              isRightOf(pL, l1, l2));
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

 
  @Test
  public void testInterpolateElevation() {
   
    assertEquals(9.0, GeometryUtil.interpolateElevation(
        new VectorXZ(5, 1),
        new VectorXYZ(3, 7, 1),
        new VectorXYZ(6, 10, 1)).y);
   
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

 
  @Test
  public void testEquallyDistributePointsAlong1StartEnd() {
   
    List<VectorXZ> result = GeometryUtil.equallyDistributePointsAlong(
        1f, true, new VectorXZ(-2, 5), new VectorXZ(+4, 5));
   
    assertSame(7, result.size());
    assertAlmostEquals(-2, 5, result.get(0));
    assertAlmostEquals(-1, 5, result.get(1));
    assertAlmostEquals( 0, 5, result.get(2));
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

  @Test
  public void testEquallyDistributePointsAlong1NoStartEnd() {
   
    List<VectorXZ> result = GeometryUtil.equallyDistributePointsAlong(
        1f, false, new VectorXZ(-2, 5), new VectorXZ(+4, 5));
   
    assertSame(6, result.size());
    assertAlmostEquals(-1.5f, 5, result.get(0));
    assertAlmostEquals(-0.5f, 5, result.get(1));
    assertAlmostEquals(+0.5f, 5, result.get(2));
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

public class VectorXZTest {
 
  @Test
  public void testRightNormal() {
   
    VectorXZ xUnitRightNormal = VectorXZ.X_UNIT.rightNormal();
    assertAlmostEquals(0, -1, xUnitRightNormal);
   
    VectorXZ testA = new VectorXZ(0.5f, 0.5f);
    VectorXZ testARightNormal = testA.rightNormal();
    assertAlmostEquals(0.707f, -0.707f, testARightNormal);
   
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

  }
 
  @Test
  public void testAngle() {
   
    assertAlmostEquals(     0, new VectorXZ( 0, +1).angle());
    assertAlmostEquals(0.5*PI, new VectorXZ(+10).angle());
    assertAlmostEquals(    PI, new VectorXZ( 0, -1).angle());
    assertAlmostEquals(1.5*PI, new VectorXZ(-10).angle());

    assertAlmostEquals(0.25*PI, new VectorXZ(1, 1).angle());
    assertAlmostEquals(0.25*PI, new VectorXZ(5, 5).angle());
   
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

    assertAlmostEquals(0.5 * PI, angleBetween(X_UNIT, Z_UNIT));
    assertAlmostEquals(0.5 * PI, angleBetween(Z_UNIT, X_UNIT));
    assertAlmostEquals(0.5 * PI, angleBetween(Z_UNIT, X_UNIT.mult(3)));
   
    assertAlmostEquals(0.25 * PI, angleBetween(
        X_UNIT, new VectorXZ(1, 1)));
    assertAlmostEquals(0.75 * PI, angleBetween(
        X_UNIT, new VectorXZ(-1, -1)));
   
  }
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.