Package rlforj.math

Examples of rlforj.math.Point2I


      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

    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

      LinkedList<bumpT> shallowBumps, LinkedList<fieldT> activeFields)
  {
//    System.out.println("-> "+steepBumps+" - "+shallowBumps);
    // 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);

    // fieldT currFld=null;

    while (!currentField.isAtEnd()
        && currentField.getCurrent().steep
View Full Code Here

    fieldT currFld = currentField.getCurrent();
    boolean ret = false;

    if (currFld.shallow.doesContain(currFld.steep.near)
        && currFld.shallow.doesContain(currFld.steep.far)
        && (currFld.shallow.doesContain(new Point2I(0, 1)) || currFld.shallow
            .doesContain(new Point2I(1, 0))))
    {
//      System.out.println("removing "+currentField.getCurrent());
      currentField.removeCurrent();
      ret = true;
    }
View Full Code Here

    }
  }

  boolean actIsBlocked(final fovStateT state, final Point2I pos)
  {
    Point2I adjustedPos = new Point2I(pos.x * state.quadrant.x
        + state.source.x, pos.y * state.quadrant.y + state.source.y);

    if(!state.board.contains(adjustedPos.x, adjustedPos.y))
      return false;//we are getting outside the board
   
View Full Code Here

  }

  void permissiveFov(int sourceX, int sourceY, permissiveMaskT mask)
  {
    fovStateT state = new fovStateT();
    state.source = new Point2I(sourceX, sourceY);
    state.mask = mask;
    state.board = mask.board;
    // state.isBlocked = isBlocked;
    // state.visit = visit;
    // state.context = context;

    final int quadrantCount = 4;
    final Point2I quadrants[] = { new Point2I(1, 1), new Point2I(-1, 1),
        new Point2I(-1, -1), new Point2I(1, -1) };

    Point2I extents[] = { new Point2I(mask.east, mask.north),
        new Point2I(mask.west, mask.north),
        new Point2I(mask.west, mask.south),
        new Point2I(mask.east, mask.south) };
    int quadrantIndex = 0;
    for (; quadrantIndex < quadrantCount; ++quadrantIndex)
    {
      state.quadrant = quadrants[quadrantIndex];
      state.extent = extents[quadrantIndex];
View Full Code Here

    mask.fovType = FovType.SQUARE;
    mask.distPlusOneSq = 0;
    mask.board = fb;

    fovStateT state = new fovStateT();
    state.source = new Point2I(startX, startY);
    state.mask = mask;
    state.board = fb;
    state.isLos = true;
    state.quadrant = new Point2I(dx < 0 ? -1 : 1, dy < 0 ? -1 : 1);
    state.quadrantIndex = 0;

    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(adx + 1, 0);
    activeFields.getLast().steep.near = new Point2I(1, 0);
    activeFields.getLast().steep.far = new Point2I(0, ady + 1);

    Point2I dest = new Point2I(0, 0);

    Line2I stopLine = new Line2I(new Point2I(0, 1), new Point2I(adx, ady + 1)), startLine = new Line2I(
        new Point2I(1, 0), new Point2I(adx + 1, ady));

    // Visit the source square exactly once (in quadrant 1).
    actIsBlocked(state, dest);

    CLikeIterator<fieldT> currentField = new CLikeIterator<fieldT>(
        activeFields.listIterator());
    int maxI = adx + ady;
    // For each square outline
    int lastStartJ = -1;
    Point2I topLeft = new Point2I(0, 0), bottomRight = new Point2I(0, 0);
    for (int i = 1; i <= maxI && !activeFields.isEmpty(); ++i)
    {
      // System.out.println("i "+i);
      int startJ = max(0, i - adx);
      startJ = max(startJ, lastStartJ - 1);
View Full Code Here

  class fieldT
  {
    public fieldT(fieldT f)
    {
      steep = new Line2I(new Point2I(f.steep.near.x, f.steep.near.y),
          new Point2I(f.steep.far.x, f.steep.far.y));
      shallow = new Line2I(
          new Point2I(f.shallow.near.x, f.shallow.near.y),
          new Point2I(f.shallow.far.x, f.shallow.far.y));
      steepBump = f.steepBump;
      shallowBump = f.shallowBump;
    }
View Full Code Here

TOP

Related Classes of 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.