Examples of VectorXZ


Examples of org.osm2world.core.math.VectorXZ

      float height = parseHeight(node.getTags(), 3.5f);
      float minHeight = height / 5;
           
      double directionAngle = parseDirection(node.getTags(), PI);
           
      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();
     
     
      /* draw board */
     
      VectorXYZ[] vsPoster = {
        getBase().add(boardVector.mult(width/2)).addY(height),
        getBase().add(boardVector.mult(width/2)).addY(minHeight),
        getBase().add(boardVector.mult(-width/2)).addY(height),
        getBase().add(boardVector.mult(-width/2)).addY(minHeight)
      };
     
      List<VectorXYZ> vsListPoster = asList(vsPoster);
     
      target.drawTriangleStrip(ADVERTISING_POSTER, vsListPoster,
          texCoordLists(vsListPoster, ADVERTISING_POSTER, STRIP_FIT));
     
      VectorXYZ[] vsBoard = {
          vsPoster[2],
          vsPoster[3],
          vsPoster[0],
          vsPoster[1]
      };
     
      List<VectorXYZ> vsListBoard = asList(vsBoard);
                 
      target.drawTriangleStrip(CONCRETE, vsListBoard,
          texCoordLists(vsListBoard, CONCRETE, STRIP_WALL));
     
     
      /* draw poles */
     
      VectorXZ[] poles = {
          node.getPos().add(boardVector.mult(-width/4)),
          node.getPos().add(boardVector.mult(+width/4))
      };
     
      for (VectorXZ pole : poles) {
        target.drawBox(CONCRETE, pole.xyz(getBase().y),
            faceVector, minHeight, 0.2, 0.1);
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

 
    if (((from == 1 && to == 0) || (from == 0 && to == 1))) {
           
      if (from == 0) {
       
        VectorXZ pos1 = startPos
          .add(cutVector.mult(startWidth));
 
        VectorXZ pos2 = endPos
          .add(cutVector.mult(endWidth));
       
        outline.add(pos1);
        outline.add(pos2);
       
      } else {
 
        VectorXZ pos1 = endPos
          .subtract(cutVector.mult(endWidth));
 
        VectorXZ pos2 = startPos
          .subtract(cutVector.mult(startWidth));
       
        outline.add(pos1);
        outline.add(pos2);
       
      }
     
    } else if (from == to
        && segments.get(from) instanceof MapWaySegment) { //usually at the end of a noexit road
     
      MapWaySegment segment = (MapWaySegment) segments.get(from);
     
      if (segment.getPrimaryRepresentation() instanceof NetworkWaySegmentWorldObject) {
       
        NetworkWaySegmentWorldObject rep =
          (NetworkWaySegmentWorldObject) segment.getPrimaryRepresentation();
       
        //TODO: the calculations for pos1/2 should be part of the NetworkLineRepresentation (it's used quite often)
       
        if (segment.getEndNode() == node) { //inbound segment
         
          VectorXZ pos1 = node.getPos()
            .add(rep.getEndOffset())
            .add(rep.getEndCutVector().mult(rep.getWidth()/2));
         
          VectorXZ pos2 = node.getPos()
            .add(rep.getEndOffset())
            .subtract(rep.getEndCutVector().mult(rep.getWidth()/2));
                   
          outline.add(pos1);
          outline.add(pos2);
         
        } else { //outbound segment
 
          VectorXZ pos1 = node.getPos()
            .add(rep.getStartOffset())
            .subtract(rep.getStartCutVector().mult(rep.getWidth()/2));
         
          VectorXZ pos2 = node.getPos()
            .add(rep.getStartOffset())
            .add(rep.getStartCutVector().mult(rep.getWidth()/2));
 
          outline.add(pos1);
          outline.add(pos2);
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

   
    if (v instanceof VectorXYZ) {
      VectorXYZ vXYZ = (VectorXYZ)v;
      return vXYZ.x + " " + vXYZ.y + " " + (-vXYZ.z);
    } else {
      VectorXZ vXZ = (VectorXZ)v;
      return vXZ.x + " " + vXZ.z;
    }
   
  }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

     
      /* calculate vectors and corners */

      double directionAngle = parseDirection(node.getTags(), PI);
     
      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();
     
      List<VectorXZ> cornerOffsets = new ArrayList<VectorXZ>(4);
      cornerOffsets.add(faceVector.mult(+0.25).add(boardVector.mult(+width/2)));
      cornerOffsets.add(faceVector.mult(+0.25).add(boardVector.mult(-width/2)));
      cornerOffsets.add(faceVector.mult(-0.25).add(boardVector.mult(+width/2)));
      cornerOffsets.add(faceVector.mult(-0.25).add(boardVector.mult(-width/2)));
     
      /* draw seat and backrest */
     
      target.drawBox(material, getBase().addY(0.5),
          faceVector, 0.05, width, 0.5);
     
      if (!node.getTags().contains("backrest", "no")) {
       
        target.drawBox(material,
            getBase().add(faceVector.mult(-0.23)).addY(0.5),
            faceVector, 0.5, width, 0.04);
       
      }
           
      /* draw poles */
           
      for (VectorXZ cornerOffset : cornerOffsets) {
        VectorXZ polePos = node.getPos().add(cornerOffset.mult(0.8));
        target.drawBox(material, polePos.xyz(getBase().y),
            faceVector, 0.5, 0.08, 0.08);
      }
     
    }
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

        material = Materials.getSurfaceMaterial(
            node.getTags().getValue("surface"), Materials.WOOD);
      }
     
      double directionAngle = parseDirection(node.getTags(), PI);
      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
     
      /* draw cross */
     
      target.drawBox(material, getBase(),
          faceVector, height, thickness, thickness);
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

    /* create MapNode for each OSM node */

    final Map<OSMNode, MapNode> nodeMap = new HashMap<OSMNode, MapNode>();

    for (OSMNode node : osmData.getNodes()) {
      VectorXZ nodePos = mapProjection.calcPos(node.lat, node.lon);
      MapNode mapNode = new MapNode(nodePos, node);
      mapNodes.add(mapNode);
      nodeMap.put(node, mapNode);
    }
   
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

  private static void addOverlapBetween(
      MapWaySegment line1, MapWaySegment line2) {
   
    if (line1.isConnectedTo(line2)) { return; }
   
    VectorXZ intersection = GeometryUtil.getLineSegmentIntersection(
        line1.getStartNode().getPos(),
        line1.getEndNode().getPos(),
        line2.getStartNode().getPos(),
        line2.getEndNode().getPos());
   
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

        intersectionPositions = new ArrayList<VectorXZ>();
        intersectingSegments = new ArrayList<MapAreaSegment>();
       
        for (MapAreaSegment areaSegment : area.getAreaSegments()) {
         
          VectorXZ intersection = segmentXZ.getIntersection(
              areaSegment.getStartNode().getPos(),
              areaSegment.getEndNode().getPos());
         
          if (intersection != null) {
            intersectionPositions.add(intersection);
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

        short value = tile.getData(x, y);
       
        double lat = tileLat + 1.0 / SRTMTile.PIXELS * (y + 0.5);
        double lon = tileLon + 1.0 / SRTMTile.PIXELS * (x + 0.5);
       
        VectorXZ pos = projection.calcPos(lat, lon);
       
        if (value != SRTMTile.BLANK_VALUE &&
            !Double.isNaN(pos.x) && !Double.isNaN(pos.z)) {
          result.add(pos.xyz(value));
        }
       
      }
    }
       
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

  private void sortLinesByAngle(List<? extends MapSegment> lines) {
    Collections.sort(lines, new Comparator<MapSegment>() {
      @Override
      public int compare(MapSegment l1, MapSegment l2) {
       
        VectorXZ d1 = l1.getDirection();
        VectorXZ d2 = l2.getDirection();
       
        if (inboundLines.contains(l1)) {
          d1 = d1.invert();
        }
        if (inboundLines.contains(l2)) {
          d2 = d2.invert();
        }
       
        //check whether the lines are in the first or second 180°
        //(the dot product formula will not be useful to distinguish
        //these cases - it only provides cos 0° to cos 180° - ,
        //so they need to be handled first)
       
        if (d1.z < 0 && d2.z > 0) {
          return -1;
        } else if (d1.z > 0 && d2.z < 0) {
          return +1;
        }
       
        //check the actual angles using the dot product with (1,0,0).
        //Two simplifications apply:
        //- we don't need to divide by the vector lengths' product,
        //  as getDirection returns vectors whose length is 1
        //- we don't need to actually calculate the angle itself,
        //  because if angle a > angle b, then cos a < cos b
        //  (in [0°, 180°])
       
        double comparison = d1.dot(X_UNIT) - d2.dot(X_UNIT);
       
        if (comparison == 0) {
          return 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.