Package org.osm2world.core.math

Examples of org.osm2world.core.math.LineSegmentXZ


     
      List<LineSegmentXZ> result = new ArrayList<LineSegmentXZ>();
     
      for (int i = 0; i+1 < positions.size(); i++) {
       
        LineSegmentXZ segment =
          new LineSegmentXZ(positions.get(i), positions.get(i+1));
       
        if (e2.getPolygon().contains(segment.getCenter())) {
          result.add(segment);
        }
       
      }
     
View Full Code Here


    /* find vertices on straight lines */
   
    for (int i = 0; i < outline.size(); i++) {
      if (GeometryUtil.distanceFromLineSegment(
        outline.get(i),
        new LineSegmentXZ(vertexBefore(outline, i),
          vertexAfter(outline, i))) < 0.001) {
        removeIndizes.add(i);
      }
    }
   
View Full Code Here

  private static final List<LineSegmentXZ> getSidesClockwise(
      AxisAlignedBoundingBoxXZ fileBoundary) {
   
    return asList(
        new LineSegmentXZ(fileBoundary.topLeft(), fileBoundary.topRight()),
        new LineSegmentXZ(fileBoundary.topRight(), fileBoundary.bottomRight()),
        new LineSegmentXZ(fileBoundary.bottomRight(), fileBoundary.bottomLeft()),
        new LineSegmentXZ(fileBoundary.bottomLeft(), fileBoundary.topLeft()));
   
  }
View Full Code Here

   * and a {@link MapArea} to both, if it exists
   */
  private static void addOverlapBetween(
      MapWaySegment line, MapArea area) {
   
    final LineSegmentXZ segmentXZ = line.getLineSegment();
   
    /* check whether the line corresponds to one of the area segments */
       
    for (MapAreaSegment areaSegment : area.getAreaSegments()) {
      if (areaSegment.sharesBothNodes(line)) {
       
        MapOverlapWA newOverlap =
          new MapOverlapWA(line, area, MapOverlapType.SHARE_SEGMENT,
              Collections.<VectorXZ>emptyList(),
              Collections.<MapAreaSegment>emptyList());
       
        line.addOverlap(newOverlap);
        area.addOverlap(newOverlap);
       
        return;
       
      }
    }
   
    /* calculate whether the line contains or intersects the area (or neither) */
   
    boolean contains;
    boolean intersects;
   
    {
      final PolygonWithHolesXZ polygon = area.getPolygon();
     
      if (!line.isConnectedTo(area)) {
 
        intersects = polygon.intersects(segmentXZ);
        contains = !intersects && polygon.contains(segmentXZ);
       
      } else {
     
        /* check whether the line intersects the area somewhere
         * else than just at the common node(s).
         */
       
        intersects = false;
     
        double segmentLength = distance(segmentXZ.p1, segmentXZ.p2);
       
        for (VectorXZ pos : polygon.intersectionPositions(segmentXZ)) {
          if (distance(pos, segmentXZ.p1) > segmentLength / 100
              && distance(pos, segmentXZ.p2) > segmentLength / 100) {
            intersects = true;
            break;
          }
        }
 
        /* check whether the area contains the line's center.
         * Unless the line intersects the area outline,
         * this means that the area contains the line itself.
         */
             
        contains = !intersects && polygon.contains(segmentXZ.getCenter());
       
      }
     
    }
   
    /* add an overlap if detected */
         
    if (contains || intersects) {
     
      /* find out which area segments intersect the way segment */

      List<VectorXZ> intersectionPositions = emptyList();
      List<MapAreaSegment> intersectingSegments = emptyList();
     
      if (intersects) {

        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

  public List<MapNode> getStartEndNodes() {
    return ImmutableList.of(startNode, endNode);
  }
 
  public LineSegmentXZ getLineSegment() {
    return new LineSegmentXZ(startNode.getPos(), endNode.getPos());
  }
View Full Code Here

     
      double posZ = box.minZ;
     
      while (posZ + upVector.z < box.maxZ) {
       
        LineSegmentXZ rowLine = new LineSegmentXZ(
             new VectorXZ(box.minX - 10, posZ),
             new VectorXZ(box.maxX + 10, posZ));
       
        // calculate start and end points (maybe more than one each)
       
View Full Code Here

     
      @Override
      public Collection<LineSegmentXZ> getInnerSegments() {
        return asList(
            ridge,
            new LineSegmentXZ(ridge.p1, cap1.p1),
            new LineSegmentXZ(ridge.p1, cap1.p2),
            new LineSegmentXZ(ridge.p2, cap2.p1),
            new LineSegmentXZ(ridge.p2, cap2.p2));
      }
View Full Code Here

     
      public HalfHippedRoof() {
       
        super(1/6.0);
       
        cap1part = new LineSegmentXZ(
            interpolateBetween(cap1.p1, cap1.p2,
                0.5 - ridgeOffset / cap1.getLength()),
            interpolateBetween(cap1.p1, cap1.p2,
                0.5 + ridgeOffset / cap1.getLength()));
       
        cap2part = new LineSegmentXZ(
            interpolateBetween(cap2.p1, cap2.p2,
                0.5 - ridgeOffset / cap1.getLength()),
            interpolateBetween(cap2.p1, cap2.p2,
                0.5 + ridgeOffset / cap1.getLength()));
       
View Full Code Here

      }
     
      @Override
      public Collection<LineSegmentXZ> getInnerSegments() {
        return asList(ridge,
            new LineSegmentXZ(ridge.p1, cap1part.p1),
            new LineSegmentXZ(ridge.p1, cap1part.p2),
            new LineSegmentXZ(ridge.p2, cap2part.p1),
            new LineSegmentXZ(ridge.p2, cap2part.p2));
      }
View Full Code Here

     
      public GambrelRoof() {
       
        super(0);
       
        cap1part = new LineSegmentXZ(
            interpolateBetween(cap1.p1, cap1.p2, 1/6.0),
            interpolateBetween(cap1.p1, cap1.p2, 5/6.0));

        cap2part = new LineSegmentXZ(
            interpolateBetween(cap2.p1, cap2.p2, 1/6.0),
            interpolateBetween(cap2.p1, cap2.p2, 5/6.0));
       
      }
View Full Code Here

TOP

Related Classes of org.osm2world.core.math.LineSegmentXZ

Copyright © 2018 www.massapicom. 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.