Tag Archives | polygon
Google Maps JavaScript API v3: how to get the center lat & lon of a polygon

Google Maps JavaScript API v3: how to get the center lat & lon of a polygon

How to get the center lat & lon of a polygon? We can do it just by calling polygon.getBounds().getCenter() Note: in Google Maps JavaScript API v2, Polygon had a getBounds() method, but that doesn’t exist for v3 Polygon. You can find that method in this article.

Read full story Comments { 0 }
PHP: How to check if a Polygon is self-intersect?

PHP: How to check if a Polygon is self-intersect?

How to check if a Polygon is self-intersect? Example 1: Result: bool(false) Example 2: Result: bool(true)

Read full story Comments { 0 }
PHP: How to determine the center of a Polygon

PHP: How to determine the center of a Polygon

How to determine the center of a Polygon. Read first: PHP: How to calculate signed area of a Polygon Method 1: Result: array(2) { [0]=> float(1.55555555556) [1]=> int(3) } Example 2: Result: array(2) { [0]=> int(0) [1]=> int(0) }

Read full story Comments { 0 }
PHP: How to check if polygon is concave or convex?

PHP: How to check if polygon is concave or convex?

How to check if polygon is concave or convex? Note: It is assumed that the polygon is simple (does not intersect itself or have holes) Example: Result: int(-1) The algorithm is built on base of the cross product of 2 vectors: We know that the cross product of 2 vectors: In the special case, 2 […]

Read full story Comments { 0 }
PHP: How to check if the vertices of polygon are in clockwise or counter-clockwise order?

PHP: How to check if the vertices of polygon are in clockwise or counter-clockwise order?

How to check if the vertices of polygon are in clockwise or counter-clockwise order? There are many of method to check this. We offer some method below: Method 1: Use ComputeArea function: Method 2: Note: It is assumed that the polygon is simple (does not intersect itself or have holes) Example: Result: int(-1)

Read full story Comments { 0 }
PHP: How to calculate signed area of a Polygon

PHP: How to calculate signed area of a Polygon

Calculating the signed area for an polygon can be found when you know the coordinates of the vertices. We offer 3 methods below: Method 1: Method 2: Method 3: Method 4: Note: If you list the points in a clockwise order instead of counterclockwise, you will get the negative of the area. Hence this can […]

Read full story Comments { 0 }
PHP: detect Point in Polygon

PHP: detect Point in Polygon

PHP function to detect Point in Polygon: Test for convex polygon: Result: IN OUT Test for concave polygon: Result: OUT IN OUT Note: we only apply this method for simple polygon (non-self-intersecting polygon). Test for complex polygon (self-intersecting polygon) Result: OUT OUT OUT Error for point 2.

Read full story Comments { 0 }