Class HexLine

java.lang.Object
megamek.client.bot.princess.geometry.HexLine

public class 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 coords, int dir)
    Create a HexLine from a point and direction
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
     
    Returns the (Euclidean distance) the 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 multivalued
    int
     
    int
     
    int
    judgeArea(ConvexBoardArea convexBoardArea)
    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 coords, int dir)
      Create a HexLine from a point and direction
  • Method Details

    • judgePoint

      public int judgePoint(Coords coords)
      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 coords)
      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(ConvexBoardArea convexBoardArea)
      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 multivalued
    • getIntersection

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

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

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

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

      public String toString()
      Overrides:
      toString in class Object