Examples of VectorXZ


Examples of org.osm2world.core.math.VectorXZ

      throw new IllegalStateException("a line must have at least two points with elevation");
    }
   
    //TODO: start pos isn't identical with first pointWithEle! can this cause problems?
   
    VectorXZ startPos = line.getPrimaryRepresentation().getStartPosition();
   
    final double posDistance = pos.subtract(startPos).length();

    // find points with known elevation directly before and after pos
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

      for (int z = 0; z < posGrid.sizeZ(); z++) {
       
        if (x % PATCH_SIZE_POINTS == 0 || x == posGrid.sizeX() - 1
            || z % PATCH_SIZE_POINTS == 0 || z == posGrid.sizeZ() - 1) {
         
          VectorXZ pos = posGrid.get(x, z);
         
          MapNode mapNode = new MapNode(pos, EMPTY_SURFACE_NODE);
         
          nodeGrid[x][z] = mapNode;
          mapNodes.add(mapNode);
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

        (VisibleConnectorNodeWorldObject)nodeRepresentation;
    }
   
    /* calculate cut as angle bisector between the two lines */
   
    VectorXZ inVector = line1.getDirection();
    VectorXZ outVector = line2.getDirection();

    if (!inbound1) { inVector = inVector.invert(); }
    if (inbound2) { outVector = outVector.invert(); }
   
    VectorXZ cutVector;
   
    if (inVector.equals(outVector)) { //TODO: allow for some small difference?
      cutVector = outVector.rightNormal();
    } else {
      cutVector = outVector.subtract(inVector);
      cutVector = cutVector.normalize();
    }
   
    //make sure that cutVector points to the right, which is equivalent to:
    //y component of the cross product (inVector x cutVector) is positive.
    //If this isn't the case, invert the cut vector.
    if (inVector.z * cutVector.x - inVector.x * cutVector.z <= 0) {
      cutVector = cutVector.invert();
    }
   
    /* set calculated cut vector */
   
    if (inbound1) {
      renderable1.setEndCutVector(cutVector);
    } else {
      renderable1.setStartCutVector(cutVector.invert());
    }
   
    if (inbound2) {
      renderable2.setEndCutVector(cutVector.invert());
    } else {
      renderable2.setStartCutVector(cutVector);
    }
   
    /* perform calculations necessary for connectors
     * whose representation requires space */
   
    double connectorLength = 0;
   
    if (visibleConnectorRep != null) {
      connectorLength = visibleConnectorRep.getLength();
    }
   
    if (connectorLength > 0) {
                 
      /* move connected lines to make room for the node's representation */
     
      //connected node of line1 is moved orthogonally to the cut vector
      VectorXZ offset1 = cutVector.rightNormal();
      offset1 = offset1.mult(connectorLength / 2);
      if (inbound1) {
        renderable1.setEndOffset(offset1);
      } else {
        renderable1.setStartOffset(offset1);
      }
     
      //node of line2 is moved into the opposite direction
      VectorXZ offset2 = offset1.invert();
      if (inbound2) {
        renderable2.setEndOffset(offset2);
      } else {
        renderable2.setStartOffset(offset2);
      }
               
      /* provide information to node's representation */
     
      if (nodeRepresentation instanceof VisibleConnectorNodeWorldObject) {
       
        VisibleConnectorNodeWorldObject connectorRep =
          (VisibleConnectorNodeWorldObject)nodeRepresentation;
       
        VectorXZ connectedPos1;
        VectorXZ connectedPos2;
       
        if (inbound1) {
          connectedPos1 = line1.getEndNode().getPos();
        } else {
          connectedPos1 = line1.getStartNode().getPos();
        }
       
        if (inbound2) {
          connectedPos2 = line2.getEndNode().getPos();
        } else {
          connectedPos2 = line2.getStartNode().getPos();
        }
       
        connectorRep.setInformation(
            cutVector,
            connectedPos1.add(offset1),
            connectedPos2.add(offset2),
            renderable1.getWidth(),
            renderable2.getWidth());
       
      }
     
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

   
    for (int i=0; i < cutCenters.size(); i++) {
     
      if (cutCenters.get(i) == null) continue;
     
      VectorXZ left = getCutNode(i, false);
      VectorXZ right = getCutNode(i, true);
     
      if (left != null) {
        vectors.add(left);
      }
      if (right != null) {
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

   */
  protected VectorXZ getCutNode(int i, boolean right) {

    checkInformationProvided();
       
    VectorXZ cutCenter = cutCenters.get(i);
    VectorXZ cutVector = cutVectors.get(i);
    Float width = widths.get(i);
   
    if (cutCenter == null) {
      return null;
    } else {
     
      if (right) {
        return cutCenter.add(cutVector.mult(width * 0.5f));
      } else {
        return cutCenter.subtract(cutVector.mult(width * 0.5f));
      }
   
    }
     
  }
 
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

    for (MapWaySegment in : inboundNLines) {
     
      NetworkWaySegmentWorldObject inRenderable =
        ((NetworkWaySegmentWorldObject)in.getPrimaryRepresentation());
     
      VectorXZ cutVector = in.getRightNormal();
      inRenderable.setEndCutVector(cutVector);
      cutVectors.add(cutVector.invert());
     
      coords.add(in.getEndNode().getPos());
      widths.add(inRenderable.getWidth());
     
    }

    for (MapWaySegment out : outboundNLines) {
     
      NetworkWaySegmentWorldObject outRenderable =
        ((NetworkWaySegmentWorldObject)out.getPrimaryRepresentation());
     
      VectorXZ cutVector = out.getRightNormal();
      outRenderable.setStartCutVector(cutVector);
      cutVectors.add(cutVector);
     
      coords.add(out.getStartNode().getPos());
      widths.add(outRenderable.getWidth());
     
    }
   
    /* move roads away from the intersection until they cannot overlap anymore,
     * this is certain if the distance between their ends' center points
     * is greater than the sum of their half-widths */
   
    //TODO (performance) if roads were ordered by angle here already, this would be much faster -> only neighbors checked
   
    boolean overlapPossible;
   
    do {
     
      overlapPossible = false;
     
      overlapCheck:
      for (int r1=0; r1 < coords.size(); r1++) {
        for (int r2=r1+1; r2 < coords.size(); r2++) {
         
          /* ignore overlapping (or almost overlapping) way segments
           * as no reasonable amount of pushing would separate these */
          if (VectorXZ.distance(connectedNSegments.get(r1).getDirection(),
              connectedNSegments.get(r2).getDirection()) < 0.1
            ||  VectorXZ.distance(connectedNSegments.get(r1).getDirection(),
                connectedNSegments.get(r2).getDirection().invert()) < 0.1) {
            continue;
          }
         
          double distance = Math.abs(coords.get(r1).subtract(coords.get(r2)).length());
         
          if (distance > 200) {
            //TODO: proper error handling
            System.err.println("distance has exceeded 200 at node " + node
                + "\n (representation: " + nodeRepresentation + ")");
            // overlapCheck will remain false, no further size increase
            break overlapCheck;
          }
         
          if (distance <= widths.get(r1)*0.5 + widths.get(r2)*0.5) {
            overlapPossible = true;
            break overlapCheck;
          }
         
        }
      }
   
      if (overlapPossible) {
       
        /* push outwards */
       
        coords.clear();
       
        for (MapWaySegment in : inboundNLines) {
         
          NetworkWaySegmentWorldObject inRenderable =
            ((NetworkWaySegmentWorldObject)in.getPrimaryRepresentation());
          VectorXZ inVector = in.getDirection();
         
          VectorXZ offsetModification = inVector.mult(-ROAD_PUSHING_STEP);
         
          VectorXZ newEndOffset = inRenderable.getEndOffset().add(offsetModification);
          inRenderable.setEndOffset(newEndOffset);
          coords.add(in.getEndNode().getPos().add(newEndOffset));
         
        }

        for (MapWaySegment out : outboundNLines) {
         
          NetworkWaySegmentWorldObject outRenderable =
            ((NetworkWaySegmentWorldObject)out.getPrimaryRepresentation());
          VectorXZ outVector = out.getDirection();
         
          VectorXZ offsetModification = outVector.mult(ROAD_PUSHING_STEP);
         
          VectorXZ newStartOffset = outRenderable.getStartOffset().add(offsetModification);
          outRenderable.setStartOffset(newStartOffset);
          coords.add(out.getStartNode().getPos().add(newStartOffset));
         
        }
       
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

  /**
   * @param l  line with {@link NetworkWaySegmentWorldObject} as representation
   */
  private static void setOrthogonalCutVector(MapWaySegment l, boolean setStartVector) {

    VectorXZ cutVector = l.getRightNormal();
   
    NetworkWaySegmentWorldObject lRepresentation =
      (NetworkWaySegmentWorldObject)l.getPrimaryRepresentation();
   
    if (setStartVector) {
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

     
    int i = from;
   
    while (i != to) {
        
      VectorXZ newNodeA = getCutNode(i, false);
      if (newNodeA != null) {
        outline.add(newNodeA);
      }
 
      int nextI = i - 1;
      if (nextI < 0) { nextI = segments.size() - 1; }
 
      VectorXZ newNodeB = getCutNode(nextI, true);
      if (newNodeB != null) {
        outline.add(newNodeB);
      }
 
      i = nextI;
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

        if (primTexCoordLists == null && material.getNumTextureLayers() > 0) {
          System.out.println(material);
        }
         
        for (int t = 0; t < material.getNumTextureLayers(); t++) {
          VectorXZ textureCoord =  primTexCoordLists.get(t).get(i);
          put(buffer, textureCoord);
        }
       
        put(buffer, primNormals.get(i));
        put(buffer, primVertices.get(i));
View Full Code Here

Examples of org.osm2world.core.math.VectorXZ

       
        for (NodeSequence coastline : origCoastlines) {
       
          for (int i = 0; i + 1 < coastline.size(); i++) {
           
            VectorXZ r1 = coastline.get(i).getPos();
            VectorXZ r2 = coastline.get(i + 1).getPos();
           
            VectorXZ intersection = getLineSegmentIntersection(
                side.p1, side.p2, r1, r2);
           
            if (intersection != null) {
           
              MapNode intersectionNode;
             
              if (intersection.equals(r1)) {
                intersectionNode = coastline.get(i);
              } else if (intersection.equals(r2)) {
                intersectionNode = coastline.get(i + 1);
              } else {
               
                intersectionNode = createFakeMapNode(intersection,
                    ++highestNodeId, osmData, nodeMap, mapNodes);
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.