Package transientlibs.rlforj.math

Examples of transientlibs.rlforj.math.Point2I


      CLikeIterator<fieldT> currentField, LinkedList<bumpT> steepBumps,
      LinkedList<bumpT> shallowBumps, LinkedList<fieldT> activeFields)
  {
    // System.out.println("visitsq called "+dest);
    // The top-left and bottom-right corners of the destination square.
    Point2I topLeft = new Point2I(dest.x, dest.y + 1);
    Point2I bottomRight = new Point2I(dest.x + 1, dest.y);
//    System.out.println(dest);
    // fieldT currFld=null;

    boolean specialCase=false;
   
View Full Code Here


   * @param pos
   * @return
   */
  boolean actIsBlockedCone(final coneFovState state, final Point2I pos)
  {
    final Point2I stateQuadrant = state.quadrant;
    Point2I adjustedPos = new Point2I(pos.x * stateQuadrant.x
        + state.source.x, pos.y * stateQuadrant.y + state.source.y);
   
    //Keep track of which axes are done.
    if (
           (pos.x==0 && stateQuadrant.y>0 && !state.axisDone[1])
View Full Code Here

    {
      int dx = x - sx;
      dx = dx > 0 ? dx : -dx;
      int dy = y - sy;
      dy = dy > 0 ? dy : -dy;
      visitedNotObs.add(new Point2I(dx, dy));
    }
    //DEBUG
//    b.visit(x, y);
  }
View Full Code Here

    // too lazy
    // for (int i = 0; i < r.width; i++) {
    // for (int j = 0; j < r.height; j++) {
    // RLPoint p = RLPoint.point(r.x + i, r.y + j);
    // points.add(p);
    Point2I p = new Point2I(x, y);
    b.visit(x, y);
    go(b, p, 1, distance, 0.0, 359.9);
    // }
    // }
View Full Code Here

      signY=-1;
    }
    RecordQuadrantVisitBoard fb = new RecordQuadrantVisitBoard(b, startX, startY, x1, y1,
        calculateProject);

    Point2I p = new Point2I(startX, startY);
   
    if (startY==y1 && x1>startX) {
      int distance=dx+1;
      double deg1=Math.toDegrees(Math.atan2(.25, dx));//very thin angle
      go(fb, p, 1, distance, -deg1, 0);
View Full Code Here

    if (b == null)
      throw new IllegalArgumentException();
    if (distance < 1)
      throw new IllegalArgumentException();

    Point2I p = new Point2I(x, y);
    b.visit(x, y);
    if(startAngle>finishAngle) {
      go(b, p, 1, distance, startAngle, 359.999);
      go(b, p, 1, distance, 0.0, finishAngle);
    }
View Full Code Here

    // System.out.println("adx ady "+adx+" "+ady);
    //calculate the two error values.
    int incE = 2 * ady; //error diff if x++
    int incNE = 2 * ady - 2 * adx; // error diff if x++ and y++
    int d = 2 * ady - adx; // starting error
    Point2I p = new Point2I(0, 0);
    int lasti = 0, lastj = 0;
    int j = 0;
    for (int i = 0; i <= adx;)
    {
      lasti = i;
      lastj = j;
      if(axesSwapped){
        i=p.y; j=p.x;
      } else {
        i=p.x; j=p.y;
      }
       System.out.println("GCP loop "+i+" "+j+" d "+d);
       if(d<-2*adx) System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
      if(i>adx || j>ady) // searching outside range
      {
        System.out.println("Outside range "+i+" "+j+" "+adx+" "+ady);
        break;
      }
     
      if (axesSwapped) {
        path.add(new Point2I(
            (j * signX + startX),
            (i * signY + startY)));
      } else {
        path.add(new Point2I(
        (i * signX + startX),
        (j * signY + startY)));
      }
      System.out.println("Added to path "+path.lastElement());
      if(i==adx && j==ady)//end reached and recorded
      {
        System.out.println("End reached and recorded ");
        break;
      }
     
      boolean ippNotrecommended = false;//whether i++ is recommended
      if (d <= 0)
      {
        // try to just inc x
        if (axesSwapped)
        {
          p.y = i + 1;
          p.x = j;
        } else
        {
          p.x = i + 1;
          p.y = j;
        }
        if (fb.wasVisited(p.x, p.y) || /* end */ (i==adx && j==ady))
        {
          d += incE;
//          i++;
          continue;
        }
        // System.out.println("cannot i++ "+p+"
        // "+fb.visitedNotObs.contains(p));
      } else
      {
        // System.out.println("i++ not recommended ");
        ippNotrecommended = true;
      }

      // try to inc x and y
      if (axesSwapped)
      {
        p.y = i + 1;
        p.x = j + 1;
      } else
      {
        p.x = i + 1;
        p.y = j + 1;
      }
      if (fb.wasVisited(p.x, p.y) || /* end */ (i==adx && j==ady))
      {
        d += incNE;
//        j++;
//        i++;
        continue;
      }
      // System.out.println("cannot i++ j++ "+p+"
      // "+fb.visitedNotObs.contains(p));
      if (ippNotrecommended)
      { // try it even if not recommended
        if (axesSwapped)
        {
          p.y = i + 1;
          p.x = j;
        } else
        {
          p.x = i + 1;
          p.y = j;
        }
        if (fb.wasVisited(p.x, p.y) || /* end */ (i==adx && j==ady))
        {
          d += incE;
//          i++;
          continue;
        }
        // System.out.println("cannot i++ "+p+"
        // "+fb.visitedNotObs.contains(p));
      }
      // last resort
      // try to inc just y
      if (axesSwapped)
      {
        p.y = i;
        p.x = j + 1;
      } else
      {
        p.x = i;
        p.y = j + 1;
      }
      if (fb.wasVisited(p.x, p.y) || /* end */ (i==adx && j==ady))
      {
        System.out.println("GCP y++ "+i+" "+j+" last "+lasti+" "+lastj);
        if (lasti == i - 1 && lastj == j)// last step was 1 to the
          // right
          System.out.println("<<- GenericCalculateProj check code");
        // this step is 1 step to up,
        // together 1 diagonal
        // => we dont need last point
       
        d += -incE + incNE;// as if we went 1 step left then took 1
        // step up right
//        j++;
        continue;
      }
      // System.out.println("cannot j++ "+p+"
      // "+fb.visitedNotObs.contains(p));
      // no path, end here, after adding last point.
      if (axesSwapped) {
        path.add(new Point2I(
            (j * signX + startX),
            (i * signY + startY)));
      } else {
        path.add(new Point2I(
        (i * signX + startX),
        (j * signY + startY)));
      }
      break;
    }
View Full Code Here

  private int dsq;
 
  public void visitFieldOfView(ILosBoard b, int x, int y, int distance)
  {
    this.world = b;
    this.origin = new Point2I(x, y);
    this.perimeter = new LinkedList<RayData>();
    this.results = new RayData[2*distance+1][2*distance+1];
   
    offset = new Point2I(distance, distance);
    dsq=distance*distance;
    b.visit(x, y);
    castRays();
//    printResults();
  }
View Full Code Here

//    printResults();
  }
 
  public MultiRaysCaster(ILosBoard world, int originX, int originY, int radius) {
    this.world = world;
    this.origin = new Point2I(originX, originY);
    this.perimeter = new LinkedList<RayData>();
    this.results = new RayData[2*radius+1][2*radius+1];
   
    offset = new Point2I(radius, radius);
    dsq=radius*radius;
  }
 
View Full Code Here

    LinkedList<bumpT> steepBumps = new LinkedList<bumpT>();
    LinkedList<bumpT> shallowBumps = new LinkedList<bumpT>();
    // activeFields is sorted from shallow-to-steep.
    LinkedList<fieldT> activeFields = new LinkedList<fieldT>();
    activeFields.addLast(new fieldT());
    activeFields.getLast().shallow.near = new Point2I(0, 1);
    activeFields.getLast().shallow.far = new Point2I(state.extent.x, 0);
    activeFields.getLast().steep.near = new Point2I(1, 0);
    activeFields.getLast().steep.far = new Point2I(0, state.extent.y);

    Point2I dest = new Point2I(0, 0);

    // Visit the source square exactly once (in quadrant 1).
    if (state.quadrant.x == 1 && state.quadrant.y == 1)
    {
      actIsBlocked(state, dest);
View Full Code Here

TOP

Related Classes of transientlibs.rlforj.math.Point2I

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.