Package org.osm2world.core.math

Examples of org.osm2world.core.math.VectorXZ


        return contains(((MapNode)element).getPos());
       
      } else if (element instanceof MapWaySegment) {
        MapWaySegment line = (MapWaySegment)element;
               
        VectorXZ lineStart = line.getStartNode().getPos();
        VectorXZ lineEnd = line.getEndNode().getPos();
       
        if (contains(lineStart) || contains(lineEnd)) {
          return true;
        } else if (boundary.intersects(lineStart, lineEnd)) {
          //SUGGEST (performance): use that the box is axis-aligned?
View Full Code Here


      return height;
    }
   
    private VectorXZ[][] getCorners(VectorXZ center, double diameter) {
      double half = diameter/2;
      VectorXZ ortho = direction.rightNormal();
     
      VectorXZ right_in = center.add(direction.mult(half));
      VectorXZ left_in = center.add(direction.mult(-half));
      VectorXZ right_out = center.add(direction.mult(half));
      VectorXZ left_out = center.add(direction.mult(-half));

      // TODO: if we can switch off backface culling we'd only need one face here
      return new VectorXZ[][]{
          new VectorXZ[]{
              right_in.add(ortho.mult(-half)),
              right_in.add(ortho.mult(half)),
              left_in.add(ortho.mult(half)),
              left_in.add(ortho.mult(-half))
          },
          new VectorXZ[]{
              right_out.add(ortho.mult(half)),
              right_out.add(ortho.mult(-half)),
              left_out.add(ortho.mult(-half)),
              left_out.add(ortho.mult(half))
          }};
    }
View Full Code Here

       
        for (int i = 0; i < 2; i++) {
          int idx = (a+i)%4;
          vs.add(high[idx].xyz(height));
          vs.add(low[idx].xyz(base));
          tex.add(new VectorXZ(i, 1));
          tex.add(new VectorXZ(i, 0));
        }
       
        target.drawTriangleStrip(Materials.POWER_TOWER_VERTICAL, vs, texList);
      }
    }
View Full Code Here

      vs.add(right.xyz(base));
      vs.add(left.xyz(base));
      vs.add(right.xyz(base+right_height));
      vs.add(left.xyz(base+left_height));
   
      tex.add(new VectorXZ(1, 1));
      tex.add(new VectorXZ(0, 1));
      tex.add(new VectorXZ(1, 0));
      tex.add(new VectorXZ(0, 0));
   
      target.drawTriangleStrip(Materials.POWER_TOWER_HORIZONTAL, vs, texList);
    }
View Full Code Here

     
      this.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
                   
          VectorXZ point = inverseCoord(e.getX(), e.getY());
         
          if (e.getButton() == MouseEvent.BUTTON1) {
            probePos = point;
          } else {
            add(point.xyz(0));
          }
         
          NNDebugPanel.this.repaint(0);
         
        }
View Full Code Here

            nCopies(Materials.POWER_TOWER_VERTICAL.getNumTextureLayers(), tex);

        for (int i = 0; i < 2; i++) {
          vs.add(points[1][a+i].xyz(base + height[a+i]));
          vs.add(points[2][a+i].xyz(base + height[a+i]));
          tex.add(new VectorXZ(0, i));
          tex.add(new VectorXZ(1, i));
        }
        target.drawTriangleStrip(Materials.POWER_TOWER_VERTICAL, vs, texList);
      }
    }
View Full Code Here

    private void drawHorizontalPole(Target<?> target, double elevation,
        double diameter, double width) {

      double half = diameter / 2;
      VectorXZ ortho = direction.rightNormal();

      // TODO: if we can switch off backface culling we'd only need one face here
      VectorXZ[][] draw = new VectorXZ[][] {
          getPoleCoordinates(node.getPos().add(direction.mult(-half)), ortho, width, half),
          getPoleCoordinates(node.getPos().add(direction.mult(-half)), ortho.invert(), width, half),
          getPoleCoordinates(node.getPos().add(direction.mult(half)), ortho.invert(), width, half),
          getPoleCoordinates(node.getPos().add(direction.mult(half)), ortho, width, half)
      };

      for (int i = 0; i < 4; i++) {
        drawHorizontalSegment(target, draw[i][0], draw[i][1], elevation, 0.1, diameter/2);
View Full Code Here

             
        g.setColor(Color.GREEN);
       
        for (DelaunayTriangle t : triangulation.getIncidentTriangles(p)) {
 
          VectorXZ center = t.getCircumcircleCenter();
          double radius = t.p0.distanceToXZ(center);
       
          draw(g, center);
          drawCircle(g, center, radius);
                   
        }
       
      }
             
      /* draw triangles */
     
      g.setColor(Color.RED);
     
      for (DelaunayTriangle triangle : triangulation.getTriangles()) {
        draw(g, triangle.asTriangleXZ());
      }
           
      /* draw points */
     
      g.setColor(Color.BLACK);
     
      for (VectorXYZ p : points) {
        draw(g, p.xz());
      }
     
      /* draw click data */
     
      if (probePos != null) {
       
        draw(g, probePos);
               
        NaturalNeighbors nn = triangulation.probe(probePos);
       
        for (int i = 0; i < nn.neighbors.length; i++) {
         
          VectorXZ neighbor = nn.neighbors[i].xz();
          double relativeWeight = nn.relativeWeights[i];
         
          drawLine(g, probePos, neighbor);
         
          g.drawString(String.format(Locale.US, "%.3f", relativeWeight),
View Full Code Here

          coordX(p2), coordY(p2));
    }

    private void drawCircle(Graphics g, VectorXZ center, double radius) {
     
      VectorXZ bottomLeft = center.add(new VectorXZ(-radius, radius));
      VectorXZ topRight = center.add(new VectorXZ(radius, -radius));
           
      g.drawOval(
          coordX(bottomLeft), coordY(bottomLeft),
          coordX(topRight) - coordX(bottomLeft),
          coordY(topRight) - coordY(bottomLeft));
View Full Code Here

   
    private void drawArrow(Graphics g, VectorXZ p1, VectorXZ p2) {
     
      drawLine(g, p1, p2);
           
      VectorXZ arrowVector = p2.subtract(p1);
      VectorXZ arrowDir = arrowVector.normalize();
      double headSize = (maxX - minX) / 25;
           
      VectorXZ headBase = p2.subtract(arrowDir.mult(headSize));
      VectorXZ headRight = headBase.add(arrowDir.rightNormal().mult(0.5*headSize));
      VectorXZ headLeft = headBase.subtract(arrowDir.rightNormal().mult(0.5*headSize));
     
      drawLine(g, headRight, p2);
      drawLine(g, headLeft, p2);
     
    }
View Full Code Here

TOP

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

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.