Package org.osm2world.core.math

Examples of org.osm2world.core.math.LineSegmentXZ


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


        rings = (int)Math.max(3, roofHeight/ROOF_SUBDIVISION_METER);
        capParts = new ArrayList<LineSegmentXZ>(rings*2);
        // TODO: would be good to vary step size with slope
        float step = 0.5f / (rings + 1);
        for (int i = 1; i <= rings; i++) {
          capParts.add(new LineSegmentXZ(
              interpolateBetween(cap1.p1, cap1.p2, i * step),
              interpolateBetween(cap1.p1, cap1.p2, 1 - i * step)));

          capParts.add(new LineSegmentXZ(
              interpolateBetween(cap2.p1, cap2.p2, i * step),
              interpolateBetween(cap2.p1, cap2.p2, 1 - i * step)));
        }
      }
 
View Full Code Here

      public Collection<LineSegmentXZ> getInnerSegments() {

        List<LineSegmentXZ> innerSegments = new ArrayList<LineSegmentXZ>(rings * 2 + 1);
        innerSegments.add(ridge);
        for (int i = 0; i < rings * 2; i += 2) {
          LineSegmentXZ cap1part = capParts.get(i);
          LineSegmentXZ cap2part = capParts.get(i+1);
          innerSegments.add(new LineSegmentXZ(cap1part.p1, cap2part.p2));
          innerSegments.add(new LineSegmentXZ(cap1part.p2, cap2part.p1));
        }

        return innerSegments;
      }
View Full Code Here

     
      public MansardRoof() {
       
        super(1/3.0);
       
        mansardEdge1 = new LineSegmentXZ(
            interpolateBetween(cap1.p1, ridge.p1, 1/3.0),
            interpolateBetween(cap2.p2, ridge.p2, 1/3.0));

        mansardEdge2 = new LineSegmentXZ(
            interpolateBetween(cap1.p2, ridge.p1, 1/3.0),
            interpolateBetween(cap2.p1, ridge.p2, 1/3.0));
       
      }
View Full Code Here

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

            simplified.add(v);
            vPrev = v;
            continue;
          }
          VectorXZ vNext = vertices.get(i + 1);
          LineSegmentXZ l = new LineSegmentXZ(vPrev, vNext);
         
          // TODO define as static somewhere: 10 cm tolerance
          if (distanceFromLineSegment(v, l) < 0.01){
            continue;
          }
View Full Code Here

            segments.addAll(hole.getSegments());
          }
         
          // find the segment with the closest distance to the node
         
          LineSegmentXZ closestSegment = null;
          double closestSegmentDistance = Double.MAX_VALUE;
         
          for (LineSegmentXZ segment : segments) {
            double segmentDistance = distanceFromLineSegment(v, segment);
            if (segmentDistance < closestSegmentDistance) {
View Full Code Here

       
        apex = outerPoly.getCentroid();
       
        innerSegments = new ArrayList<LineSegmentXZ>();
        for (VectorXZ v : outerPoly.getVertices()) {
          innerSegments.add(new LineSegmentXZ(v, apex));
        }
       
      }
View Full Code Here

           * with segments of the polygon */
         
          VectorXZ center = simplifiedOuter.getCentroid();
         
          Collection<LineSegmentXZ> intersections =
              simplifiedOuter.intersectionSegments(new LineSegmentXZ(
                center.add(slopeDirection.mult(-1000)), center));
         
          LineSegmentXZ outermostIntersection = null;
          double distanceOutermostIntersection = -1;
         
          for (LineSegmentXZ i : intersections) {
            double distance = distanceFromLineSegment(center, i);
            if (distance > distanceOutermostIntersection) {
View Full Code Here

          }
        }
       
        if (ridgeDirection == null) {
         
          LineSegmentXZ longestSeg = MinMaxUtil.max(
              simplifiedPolygon.getSegments(),
              new Function<LineSegmentXZ, Double>() {
                public Double apply(LineSegmentXZ s) {
                  return s.getLength();
                };
              });
         
          ridgeDirection =
            longestSeg.p2.subtract(longestSeg.p1).normalize();
         
          if (area.getTags().contains("roof:orientation", "across")) {
            ridgeDirection = ridgeDirection.rightNormal();
          }
         
        }
       
        /* calculate the two outermost intersections of the
         * quasi-infinite ridge line with segments of the polygon */
       
        VectorXZ p1 = outerPoly.getCentroid();
       
        Collection<LineSegmentXZ> intersections =
          simplifiedPolygon.intersectionSegments(new LineSegmentXZ(
              p1.add(ridgeDirection.mult(-1000)),
              p1.add(ridgeDirection.mult(1000))
          ));

        if (intersections.size() < 2) {
          throw new InvalidGeometryException(
              "cannot handle roof geometry for id "
                  + area.getOsmObject().id);
        }
       
        //TODO choose outermost instead of any pair of intersections
        Iterator<LineSegmentXZ> it = intersections.iterator();
        cap1 = it.next();
        cap2 = it.next();
       
        /* base ridge on the centers of the intersected segments
         * (the intersections itself are not used because the
         * tagged ridge direction is likely not precise)       */

        VectorXZ c1 = cap1.getCenter();
        VectorXZ c2 = cap2.getCenter();
       
        ridgeOffset = min(
            cap1.getLength() * relativeRoofOffset,
            0.4 * c1.distanceTo(c2));
       
        if (relativeRoofOffset == 0) {
         
          ridge = new LineSegmentXZ(c1, c2);
         
        } else {
         
          ridge = new LineSegmentXZ(
              c1.add( p1.subtract(c1).normalize().mult(ridgeOffset) ),
              c2.add( p1.subtract(c2).normalize().mult(ridgeOffset) ));
         
        }
       
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.