Package javax.vecmath

Examples of javax.vecmath.Vector2d


  }

  private void renderCurrentRoboter(Graphics g) {
    LightSensor leftLightSensor = roboter.getLeftLightSensor();
    LightSensor rightLightSensor = roboter.getRightLightSensor();
    Vector2d directionVector = roboter.getDirection();
    if (renderRoboter) {
      g.setColor(color);
      SlickRenderUtils.fillCircle(g, roboter.getX(), roboter.getY(), 3);
      if (selected) {
        g.setColor(Color.yellow);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 4);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 5);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 6);
      }
      g.setColor(color);
      double currentDirectionPointX = roboter.getX() + directionPointLength * directionVector.getX();
      double currentDirectionPointY = roboter.getY() + directionPointLength * directionVector.getY();
      g.drawLine((float) roboter.getX(), (float) roboter.getY(), (float) currentDirectionPointX, (float) currentDirectionPointY);

      drawMotor(g, roboter.getLeftMotor());
      drawMotor(g, roboter.getRightMotor());

View Full Code Here


  private void drawLightSensorViewField(Graphics g, final LightSensor sensor, Vector2d directionVector,
      RoboterConstruction roboterConstruction) {
    Point2d lightSensorPoint = roboterConstruction.getRoboterElementPoint(sensor);

    Vector2d vec1 = roboterConstruction.getRoboterElementAngleVector(sensor);
    Point2d viewDirectionPoint = VecMathUtils.getScaledVectorPoint(vec1, lightSensorPoint, 50);
    String strring = "" + (int) sensor.getSensorIntensity();

    Point2d viewDirectionPoint2 = VecMathUtils.getScaledVectorPoint(vec1, lightSensorPoint, 52);
    g.drawString(strring, (float) viewDirectionPoint2.getX(), (float) viewDirectionPoint2.getY());

    double angleMinMax = sensor.getViewFieldSize() / 2;
    Vector2d vecMinViewField = VecMathUtils.rotateVector(vec1, angleMinMax);
    Vector2d vecMaxViewField = VecMathUtils.rotateVector(vec1, -angleMinMax);
    Point2d vecMinViewFieldPoint = VecMathUtils.getScaledVectorPoint(vecMinViewField, lightSensorPoint, 300);
    Point2d vecMaxViewFieldPoint = VecMathUtils.getScaledVectorPoint(vecMaxViewField, lightSensorPoint, 300);
    // drawLine(lightSensorPoint, vecMinViewFieldPoint, g);
    // drawLine(lightSensorPoint, vecMaxViewFieldPoint, g);
View Full Code Here

  }

  @Override
  public double calculateIntensity(Point2d lightSensorPoint, LightSensor lightSensor, Vector2d lightSensorVector) {

    Vector2d distanceVector = buildLightBulbToPointVector(lightSensorPoint);
    double distance = distanceVector.length();
    if (distance > lightBulb.getMaxRadius()) {
      return 0;
    }
    double intensity = calculateGeneralDistanceLightIntensity(distance);
View Full Code Here

    double intensity = term1 / term2;
    return intensity;
  }

  private Vector2d buildLightBulbToPointVector(Point2d lightSensorPoint) {
    Vector2d distanceVector = new Vector2d(lightBulb.getX() - lightSensorPoint.getX(), lightBulb.getY() - lightSensorPoint.getY());
    return distanceVector;
  }
View Full Code Here

    }
  }

  private void redirectRobotToPoint(RoboterComponent rc, Point2d mouseClickedPointPosition) {
    Roboter roboter = rc.getModelObject();
    Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY() - roboter.getY());
    vec.normalize();
    roboter.setDirection(vec);
  }
View Full Code Here

  private void redirectRobotsToPoint(Point2d mouseClickedPointPosition) {
    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      Roboter roboter = rc.getModelObject();
      Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY()
          - roboter.getY());
      vec.normalize();
      roboter.setDirection(vec);
    }
  }
View Full Code Here

    double newRoboterPointX = (leftSpeedPoint.getX() + rightSpeedPoint.getX()) / 2;
    double newRoboterPointY = (leftSpeedPoint.getY() + rightSpeedPoint.getY()) / 2;
    Point2d newRoboterPoint = new Point2d(newRoboterPointX, newRoboterPointY);

    Vector2d topVektor = new Vector2d(rightSpeedPoint.getX() - leftSpeedPoint.getX(), rightSpeedPoint.getY() - leftSpeedPoint.getY());
    topVektor.normalize();
    Vector2d newDirectionVector = new Vector2d(topVektor.getY(), -topVektor.getX());

    RoboterMove rmove = new RoboterMove(roboter, newRoboterPoint, newDirectionVector);

    return rmove;
  }
View Full Code Here

    return getRoboterRoboterElementPoint(new Point2d(roboter.getX(), roboter.getY()), roboter.getDirection(),
        roboterElements.getDistanceX());
  }

  private Point2d getRoboterRoboterElementPoint(Point2d roboterPoint, Vector2d direction, double distance) {
    Vector2d horiziontalVector = buildRightAngleVector(direction);
    double x = roboterPoint.getX() + (distance) * horiziontalVector.getX();
    double y = roboterPoint.getY() + (distance) * horiziontalVector.getY();
    return new Point2d(x, y);
  }
View Full Code Here

  }

  @Override
  public Vector2d getRoboterElementAngleVector(RoboterElement roboterElement) {
    double sensorAngle = roboterElement.getElementAngle();
    Vector2d sensorVector = VecMathUtils.rotateVector(roboter.getDirection(), sensorAngle);
    return sensorVector;

  }
View Full Code Here

    return sensorVector;

  }

  private Vector2d buildRightAngleVector(Vector2d vector) {
    Vector2d horizontalVector = new Vector2d(-vector.getY(), vector.getX());
    horizontalVector.normalize();
    return horizontalVector;
  }
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2d

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.