Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool IsInPolygon(Polygon polygon, Location CurrentPosition)
- {
- LineEntity F1 = new LineEntity(polygon.Positions[0], polygon.Positions[1]);
- LineEntity F2 = new LineEntity(polygon.Positions[1], polygon.Positions[2]);
- LineEntity F3 = new LineEntity(polygon.Positions[2], polygon.Positions[3]);
- LineEntity F4 = new LineEntity(polygon.Positions[3], polygon.Positions[0]);
- // The end of first ray
- Position B = new Position(CurrentPosition.Longitude + 34.282828, CurrentPosition.Latitude + 83.181772626);
- // The end of second ray
- Position C = new Position(CurrentPosition.Longitude + 23.2828828, CurrentPosition.Latitude + 12.001827);
- LineEntity AB = new LineEntity(CurrentPosition, B);
- LineEntity AC = new LineEntity(CurrentPosition, C);
- int ABCounter = 0;
- if (lineInteractor.IfIntersect(AB, F1))
- ABCounter++;
- if (lineInteractor.IfIntersect(AB, F2))
- ABCounter++;
- if (lineInteractor.IfIntersect(AB, F3))
- ABCounter++;
- if (lineInteractor.IfIntersect(AB, F4))
- ABCounter++;
- int ACCounter = 0;
- if (lineInteractor.IfIntersect(AC, F1))
- ACCounter++;
- if (lineInteractor.IfIntersect(AC, F2))
- ACCounter++;
- if (lineInteractor.IfIntersect(AC, F3))
- ACCounter++;
- if (lineInteractor.IfIntersect(AC, F4))
- ACCounter++;
- if (ABCounter % 2 == 1 && ACCounter % 2 == 1)
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement