Class HexLine
java.lang.Object
megamek.client.bot.princess.geometry.HexLine
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.
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
-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 -
Method Summary
Modifier and TypeMethodDescriptionbooleangetClosestPoint(Coords coords) Returns the (Euclidean distance) the closest point on this line to another pointgetIntersection(HexLine hexLine) Returns the intersection point with another line if lines are parallel (even if they are coincident) returns nullintgetYFromX(int x) This function only makes sense for directions 1, 2, 4, 5 Note that the function getXFromY would be multivaluedinthashCode()intisAbsoluteLeftOrRight(Coords coords) intjudgeArea(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 lineintjudgePoint(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.toString()
-
Constructor Details
-
HexLine
Create aHexLinefrom a point and direction
-
-
Method Details
-
judgePoint
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
- 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
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
Returns the intersection point with another line if lines are parallel (even if they are coincident) returns null -
getClosestPoint
Returns the (Euclidean distance) the closest point on this line to another point -
equals
-
hashCode
public int hashCode() -
toString
-