Class BotGeometry.HexLine

java.lang.Object
megamek.client.bot.princess.BotGeometry.HexLine
Enclosing class:
BotGeometry

public static class BotGeometry.HexLine extends Object
This describes a line in one of the 6 directions in board space ---copied from Coords--- Coords stores x and y values. Since these are hexes, coordinates with odd x values are a half-hex down. Directions work clockwise around the hex, starting with zero at the top.
       -y
        0
      _____
   5 /     \ 1
 -x /       \ +x
    \       /
   4 \_____/ 2
        3
       +y
 
------------------------------
Direction is stored as above, but the meaning of 'intercept' depends on the direction. For directions 0, 3, intercept means the y=0 intercept for directions 1, 2, 4, 5 intercept is the x=0 intercept
  • Constructor Summary

    Constructors
    Constructor
    Description
    HexLine(Coords c, int dir)
    Create a hexline from a point and direction
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Returns the (euclidian distance) closest point on this line to another point
    Returns the intersection point with another line if lines are parallel (even if they are coincident) returns null
    int
    getYfromX(int x)
    This function only makes sense for directions 1, 2, 4, 5 Note that the function getXfromY would be multvalued
    int
     
    int
     
    int
    returns -1 if the area is entirely to the left of the line returns +1 if the area is entirely to the right of the line returns 0 if the area is divided by the line
    int
    returns -1 if the point is to the left of the line +1 if the point is to the right of the line and 0 if the point is on the line Note that this evaluation depends on the "view" direction of this line.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HexLine

      public HexLine(Coords c, int dir)
      Create a hexline from a point and direction
  • Method Details

    • judgePoint

      public int judgePoint(Coords c)
      returns -1 if the point is to the left of the line +1 if the point is to the right of the line and 0 if the point is on the line Note that this evaluation depends on the "view" direction of this line. The result is reversed for HexLines of opposite directions, e.g. directions 0 and 3.
    • isAbsoluteLeftOrRight

      public int isAbsoluteLeftOrRight(Coords c)
      Returns:
      -1 if the point is to the left of the line, +1 if the point is to the right of the line and 0 if the point is on the line Note that this evaluation is independent of the "view" direction of this line. The result is the same for HexLines of opposite directions, e.g. directions 0 and 3.
    • judgeArea

      public int judgeArea(BotGeometry.ConvexBoardArea a)
      returns -1 if the area is entirely to the left of the line returns +1 if the area is entirely to the right of the line returns 0 if the area is divided by the line
    • getYfromX

      public int getYfromX(int x)
      This function only makes sense for directions 1, 2, 4, 5 Note that the function getXfromY would be multvalued
    • getIntersection

      public Coords getIntersection(BotGeometry.HexLine h)
      Returns the intersection point with another line if lines are parallel (even if they are coincident) returns null
    • getClosestPoint

      public Coords getClosestPoint(Coords c)
      Returns the (euclidian distance) closest point on this line to another point
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object