Package javax.vecmath

Examples of javax.vecmath.Vector2d


   *
   * @param linearInfluence is the linear influence to apply on the object.
   * @param angularInfluence is the angular influence to apply on the object.
   */
  public void influenceSteering(Vector2d linearInfluence, double angularInfluence) {
    Vector2d li;
    if (linearInfluence!=null) {
      li = new Vector2d(linearInfluence);
      double nSpeed = li.length();
      if (nSpeed>getMaxLinearAcceleration()) {
        li.normalize();
        li.scale(getMaxLinearAcceleration());
      }
    }
    else {
      li = new Vector2d();
    }
    double ai = GeometryUtil.clamp(angularInfluence, -getMaxAngularAcceleration(), getMaxAngularAcceleration());
    this.motionInfluence = new MotionInfluence(DynamicType.STEEERING, this, li, ai);
  }
View Full Code Here


   * @param end The other atom in the line
   * @return The reflected co-ordinates
   */
  public static Point2d reflect(Point2d atomCoords, Point2d start, Point2d end) {
    // New point, representing vector from start atom to end atom
    Vector2d lineVector = new Vector2d(end.x - start.x, end.y - start.y);
   
    // Rotate by 90 degrees to get vector orthogonal to line
    Vector2d aVector = new Vector2d(-lineVector.y, lineVector.x);
   
    Vector2d newAtomVector = new Vector2d(atomCoords);
   
    // Translate so line goes through origin
    newAtomVector.sub(start);
   
    // Magic formula
    Vector2d refVect = new Vector2d(aVector);
    refVect.scale(2*aVector.dot(newAtomVector)/aVector.dot(aVector));
    newAtomVector.sub(refVect);
   
    // Translate back
    newAtomVector.add(start);
   
View Full Code Here

  public static Vector2d rotateVector(Vector2d directionVector, double angle) {
    double newVecX = directionVector.getX() * Math.cos(Math.toRadians(angle)) - directionVector.getY()
        * Math.sin(Math.toRadians(angle));
    double newVecY = directionVector.getX() * Math.sin(Math.toRadians(angle)) + directionVector.getY()
        * Math.cos(Math.toRadians(angle));
    Vector2d newVec = new Vector2d(newVecX, newVecY);
    newVec.normalize();
    return newVec;
  }
View Full Code Here

    LightSensor leftLightSensor = new LightSensor(-LIGHTSENSOR_DEFAULT_DISTANCE, -LIGHTSENSOR_DEFAULT_ANGLE,
        LIGHTSENSOR_DEFAULT_VIEWFIELDSIZE, LIGHTSENSOR_MAX_INTENSITY);
    LightSensor rightLightSensor = new LightSensor(LIGHTSENSOR_DEFAULT_DISTANCE, LIGHTSENSOR_DEFAULT_ANGLE,
        LIGHTSENSOR_DEFAULT_VIEWFIELDSIZE, LIGHTSENSOR_MAX_INTENSITY);

    Vector2d direction = new Vector2d(1, 0);
    Roboter roboter = new Roboter(ROBOTER_DEFAULT_X, ROBOTER_DEFAULT_Y, leftMotor, rightMotor, direction, leftLightSensor,
        rightLightSensor);

    return roboter;
  }
View Full Code Here

  public static Roboter createRandomRoboter(int maxX, int maxY) {
    Roboter roboter = createRoboter();
    roboter.setX(generateNumberBetweenRange(10, maxY));
    roboter.setY(generateNumberBetweenRange(10, maxY));

    Vector2d direction = new Vector2d(generateNumberBetweenRange(-100, 100), generateNumberBetweenRange(-100, 100));
    direction.normalize();
    roboter.setDirection(direction);
    return roboter;
  }
View Full Code Here

    this.y = r.getY();
    this.setLeftLightSensor(r.getLeftLightSensor());
    this.setRightLightSensor(r.getRightLightSensor());
    this.leftMotor = new Motor(r.getLeftMotor());
    this.rightMotor = new Motor(r.getRightMotor());
    this.direction = new Vector2d(r.getDirection());
  }
View Full Code Here

    public void travel(double x, double y) {
        travel(x, y, f);
    }
   
    public void travel(double x, double y, double f) {
        Vector2d v = new Vector2d(x - this.x, y - this.y);
        double length = v.lengthSquared();
       
        if(length > retractThrshSq)
            retract();
       
        if(length > 0)
View Full Code Here

        else {
            int o = orientation(vertex0,vertex1,vertex2);
            if (o!=0)
                return o;
            else {
                sides[0] = new Vector2d(vertex0);
                sides[0].sub(vertex1);
                sides[1] = new Vector2d(vertex2);
                sides[1].sub(vertex1);

                 if (sides[0].dot(sides[1]) < 0)
                    return 0;
                else
View Full Code Here

{
  public void a(com.a.a.c paramc)
  {
    d locald = (d)paramc.b();
    com.a.b.b localb1 = locald.d();
    Vector2d localVector2d = localb1.f();
    com.a.a.a.a.b.c.e.b localb = (com.a.a.a.a.b.c.e.b)paramc.c();
    com.a.b.b localb2 = localb.d();
    double d1 = com.a.a.a.a.b.b.i.a(0.0D, 0.0D, localVector2d.x, localVector2d.y);
    double d2 = com.a.a.a.a.b.b.i.a(localb1.c(), localb1.d(), localb2.c(), localb2.d());
    double d3 = StrictMath.abs(d1 - d2);
    double d4 = localVector2d.length() * StrictMath.cos(d3);
    if (d4 > 100.0D)
      paramc.a().a(new com.a.a.a.a.b.e.a(com.a.a.a.a.a.c.j, paramc.d().x, paramc.d().y));
  }
View Full Code Here

        double pu = x1 * yy + x2 * (1.0 - yy);
        double y1 = (1.0 - y) * cYm1.getV() + y * cell.getV();
        double y2 = (1.0 - y) * cYm1x.getV() + y * cX.getV();
        double pv = y1 * xx + y2 * (1.0 - xx);

        return new Vector2d(pu, pv);
    }
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.