check if a point exists in given area containing 4 vertices

前端 未结 4 924
我在风中等你
我在风中等你 2021-01-01 03:22

refering to http://www.weather.gov/directives/sym/pd01008006curr.pdf, page 8, we are given an area with four vertices in geographic coordinate system(lat and long system). I

4条回答
  •  暖寄归人
    2021-01-01 03:53

    Do you mean programmatically or mathematically? Programmatically is easy if you understand it mathematically. Basically, the vertices define lines. You just have to know which side of the lines constitutes "inside." Then, turn your vertices into equations but use less than or greater than rather than equals.

    Id est, assume you have the rectangle defined by the following equations: x=1, x=3, y=1, y=3

    If you want to know if (2,2) is inside that area, just evaluate each equation: x > 1, x < 3, y > 1, y < 3.

    If all four are true, the point is inside the area.

提交回复
热议问题