Package javax.vecmath

Examples of javax.vecmath.Point2d


  private void drawLightSensor(Graphics g, LightSensor lightSensor) {
    g.setColor(Color.red);
    if (this.hightLightRoboterModelElements.contains(lightSensor)) {
      g.setColor(Color.white);
    }
    Point2d leftLightSensorPoint = roboterConstruction.getRoboterElementPoint(lightSensor);
    SlickRenderUtils.fillCircle(g, leftLightSensorPoint.getX(), leftLightSensorPoint.getY(), 3);
  }
View Full Code Here


    Point2d leftLightSensorPoint = roboterConstruction.getRoboterElementPoint(lightSensor);
    SlickRenderUtils.fillCircle(g, leftLightSensorPoint.getX(), leftLightSensorPoint.getY(), 3);
  }

  private void drawMotor(Graphics g, Motor motor) {
    Point2d moterLeftPoint = roboterConstruction.getRoboterElementPoint(motor);
    g.setColor(Color.yellow);
    SlickRenderUtils.fillCircle(g, moterLeftPoint.getX(), moterLeftPoint.getY(), 3);
  }
View Full Code Here

    this.hightLightRoboterModelElements.remove(roboterElement);
  }

  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);

    Polygon pol = new Polygon();
    pol.addPoint((float) lightSensorPoint.getX(), (float) lightSensorPoint.getY());
    pol.addPoint((float) vecMaxViewFieldPoint.getX(), (float) vecMaxViewFieldPoint.getY());
    pol.addPoint((float) vecMinViewFieldPoint.getX(), (float) vecMinViewFieldPoint.getY());

    // GradientFill fill = new GradientFill((float) lightSensorPoint.getX(),
    // (float) lightSensorPoint.getY(), Color.lightGray,
    // (float) viewDirectionPoint.getX(), (float) viewDirectionPoint.getY(),
View Full Code Here

    renderRoboterTrack(g);
  }

  private void renderRoboterTrack(final Graphics g) {
    g.setColor(this.getColor());
    final Point2d oldPoint = new Point2d(-1, -1);
    Iterator<RoboterMove> it = moves.iterator();
    while (it.hasNext()) {
      RoboterMove roboterMoveState = it.next();
      if (oldPoint.getX() != -1) {
        g.drawLine((float) roboterMoveState.getNewRoboterPoint().getX(), (float) roboterMoveState.getNewRoboterPoint().getY(),
            (float) oldPoint.getX(), (float) oldPoint.getY());
      }
      oldPoint.setX(roboterMoveState.getNewRoboterPoint().getX());
      oldPoint.setY(roboterMoveState.getNewRoboterPoint().getY());
    }
  }
View Full Code Here

  }

  @Override
  public void update(GameContainer gc, int delta) throws SlickException {
    final Input input = gc.getInput();
    final Point2d mouseClickedPointPosition = new Point2d(input.getMouseX(), input.getMouseY());

    if (input.isKeyPressed(Input.KEY_S)) {
      simulator.setSimulating(true);
    } else if (input.isKeyPressed(Input.KEY_Q)) {
      simulator.setSimulating(false);
View Full Code Here

    this.roboterConstruction = roboterConstruction;
    this.roboterKI = roboterKI;
  }

  private RoboterMove calculateNextRoboterMove(RoboterConstruction roboterConstruction) {
    Point2d leftSpeedPoint = getRoboterMotorSpeedPoint(roboter.getLeftMotor());
    Point2d rightSpeedPoint = getRoboterMotorSpeedPoint(roboter.getRightMotor());

    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());
View Full Code Here

    return rmove;
  }

  private Point2d getRoboterMotorSpeedPoint(Motor motor) {
    Point2d motorPoint = roboterConstruction.getRoboterElementPoint(motor);
    double x = motorPoint.getX() + DELTA_T * motor.getVelocity() * roboter.getDirection().getX();
    double y = motorPoint.getY() + DELTA_T * motor.getVelocity() * roboter.getDirection().getY();
    return new Point2d(x, y);
  }
View Full Code Here

    this.roboter = roboter;
  }

  @Override
  public Point2d getRoboterElementPoint(RoboterElement roboterElements) {
    return getRoboterRoboterElementPoint(new Point2d(roboter.getX(), roboter.getY()), roboter.getDirection(),
        roboterElements.getDistanceX());
  }
View Full Code Here

  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

            Roboter roboter = roboterController.getRoboter();
            RoboterConstruction roboterConstruction = roboterController.getRoboterConstruction();
            for (LightBulbController lightBulbController : lightBulbControllers) {

              // Left Light Sensor
              Point2d leftLightSensorPoint = roboterConstruction.getRoboterElementPoint(roboter.getLeftLightSensor());
              Vector2d leftLightSensorVector = roboterConstruction.getRoboterElementAngleVector(roboter.getLeftLightSensor());

              leftSensorIntensity = leftSensorIntensity
                  + lightBulbController.calculateIntensity(leftLightSensorPoint, roboter.getLeftLightSensor(),
                      leftLightSensorVector);

              // Right Light Sensor
              Point2d rightLightSensorPoint = roboterConstruction.getRoboterElementPoint(roboter.getRightLightSensor());
              Vector2d rightLightSensorVector = roboterConstruction.getRoboterElementAngleVector(roboter
                  .getRightLightSensor());

              rightSensorIntensity = rightSensorIntensity
                  + lightBulbController.calculateIntensity(rightLightSensorPoint, roboter.getRightLightSensor(),
View Full Code Here

TOP

Related Classes of javax.vecmath.Point2d

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.