Package megamek.client.bot.princess
Class BotGeometry.HexLine
java.lang.Object
megamek.client.bot.princess.BotGeometry.HexLine
- Enclosing class:
- BotGeometry
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 TypeMethodDescriptionboolean
Returns the (euclidian distance) closest point on this line to another pointReturns the intersection point with another line if lines are parallel (even if they are coincident) returns nullint
getYfromX
(int x) This function only makes sense for directions 1, 2, 4, 5 Note that the function getXfromY would be multvaluedint
hashCode()
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 lineint
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.toString()
-
Constructor Details
-
HexLine
Create a hexline from 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 multvalued -
getIntersection
Returns the intersection point with another line if lines are parallel (even if they are coincident) returns null -
getClosestPoint
Returns the (euclidian distance) closest point on this line to another point -
equals
-
hashCode
public int hashCode() -
toString
-