Package rlforj.math

Examples of rlforj.math.Point2I


   * @param y
   * @return
   */
  public Point2I screenToCellCoords(int x, int y)
  {
    return new Point2I((x - imageStartX) / fontW, (y - imageStartY) / fontH);
  }
View Full Code Here


  public Point2I getTileCoords(Point loc)
  {
      int x = (int) (loc.getX()/fontW);
      int y = (int) (loc.getY()/fontH);
     
      return new Point2I(x, y);
  }
View Full Code Here

    BresenhamLine.plot(startX, startY, x1, y1, px, py);

    boolean los=false;
    for(int i=0; i<len; i++) {
      if(calculateProject){
        path.add(new Point2I(px[i], py[i]));
      }
      if(px[i]==x1 && py[i]==y1) {
        los=true;
        break;
      }
      if(b.isObstacle(px[i], py[i]))
        break;
    }
    // Direct path couldnt find LOS so try alternate path
    if(!los && symmetricEnabled) {
      int[] px1=null, py1=null;
      // allocate space for alternate path
      px1=new int[len]; py1=new int[len];
      // finish to start path.
      BresenhamLine.plot(x1, y1, startX, startY, px1, py1);
     
      Vector<Point2I> oldpath = path;
      path=new Vector<Point2I>(len);
      for(int i=len-1; i>-1; i--) {
        if(calculateProject){
          path.add(new Point2I(px1[i], py1[i]));
        }
        if(px1[i]==x1 && py1[i]==y1) {
          los=true;
          break;
        }
View Full Code Here

    boolean alternatePath=false;
    for(int i=0; i<len; i++) {
      // Have we reached the end ? In that case quit
      if(px[i]==x1 && py[i]==y1) {
        if(calculateProject){
          path.add(new Point2I(px[i], py[i]));
        }
        los=true;
        break;
      }
      // if we are on alternate path, is the path clear ?
      if(alternatePath && !b.isObstacle(px1[len-i-1], py1[len-i-1])) {
        if(calculateProject)
          path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
        continue;
      } else
        alternatePath=false;//come back to ordinary path
     
      //if on ordinary path, or alternate path was not clear
      if(!b.isObstacle(px[i], py[i])) {
        if(calculateProject) {
          path.add(new Point2I(px[i], py[i]));
        }
        continue;
      }
      //if ordinary path wasnt clear
      if(!b.isObstacle(px1[len-i-1], py1[len-i-1])) {
        if(calculateProject)
          path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
        alternatePath=true;//go on alternate path
        continue;
      }
      if(calculateProject)
        path.add(new Point2I(px1[len-i-1], py1[len-i-1]));
      break;
    }
   
    return los;
  }
View Full Code Here

    activeFields.addLast(new fieldT());
   
    // We decide the farthest cells that can be seen by the cone ( using
    // trigonometry.), then we set the active field to be in between them.
    if(startAngle==0) {
      activeFields.getLast().shallow.near = new Point2I(0, 1);
      activeFields.getLast().shallow.far = new Point2I(state.extent.x, 0);
    } else {
      activeFields.getLast().shallow.near = new Point2I(0, 1);
      activeFields.getLast().shallow.far = new Point2I(
          (int) Math.ceil(Math.cos(Math.toRadians(startAngle))
              * state.extent.x),
          (int) Math.floor(Math.sin(Math.toRadians(startAngle))
          * state.extent.y));
//      System.out.println(activeFields.getLast().shallow.isAboveOrContains(new offsetT(0, 10)));
    }
    if(finishAngle==90) {
      activeFields.getLast().steep.near = new Point2I(1, 0);
      activeFields.getLast().steep.far = new Point2I(0, state.extent.y);
    } else {
      activeFields.getLast().steep.near = new Point2I(1, 0);
      activeFields.getLast().steep.far = new Point2I(
          (int) Math.floor(Math.cos(Math.toRadians(finishAngle))
              * state.extent.x),
          (int) Math.ceil(Math.sin(Math.toRadians(finishAngle))
          * 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)
//    {
//      actIsBlockedCone(state, dest);
View Full Code Here

  }
  void permissiveConeFov(int sourceX, int sourceY, permissiveMaskT mask,
      int startAngle, int finishAngle)
  {
    coneFovState state = new coneFovState();
    state.source = new Point2I(sourceX, sourceY);
    state.mask = mask;
    state.board = mask.board;
    // state.isBlocked = isBlocked;
    // state.visit = visit;
    // state.context = context;

    //visit origin once
    state.board.visit(sourceX, sourceY);
   
    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[] angles=new int[12];
    angles[0]=0; angles[1]=90; angles[2]=180; angles[3]=270;
    for(int i=4; i<12; i++) angles[i]=720;//to keep them at the end
    int i=0;
View Full Code Here

      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

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.