I have a Polygon (a Hex for a board game) in Silverlight, something like;
public class GridHex : IGridShape { ..... public IList Points { get; protected set; } public bool Intersects(Point point) { ... } }
I would like to be able to say
if(myHex.Intersects(clickedPoint)) { ... }
However I'm unsure of which algorithm to use within the Intersects method - currently I'm using an internal "bounding box" inside each Hexagon to detect if a point is within it, but there must be an algorithm to figure this out? I know the coordinates for the 6 points of each Hexagon.
I was thinking I could maybe create a Silverlight Polygon and do some kind of hit testing? Of course this would be rather memory intensive (I'd be iterating a large number of Hexes to see which Hex a mouse click falls within...) so it might be better to use a mathematical formula to work out if a point is within a Hex....