Polygon

I would like to calculate the area of the polygon that I draw at runtime. Has anyone done this?

3 Replies

NG Naganathan Ganesh Babu Syncfusion Team January 31, 2018 08:53 AM UTC

Hi Allen 
 
We have created a sample to achieve your requirement. In below attached sample, we have added a PolygonArea() method to find the area of the polygon node in runtime.  
 
Code example: 
 
[VB] 
 
Private Function PolygonArea(ByVal points() As PointF) As Single 
                                    ' Add the first point to the end. 
                                    Dim num_points As Integer = points.Length 
                                    Dim pts(num_points) As PointF 
                                    points.CopyTo(pts, 0) 
                                    pts(num_points) = points(0) 
 
                                    ' Get the areas. 
                                    Dim area As Single = 0 
                                    For i As Integer = 0 To num_points - 1 
                                                area += (pts(i + 1).X - pts(i).X) * (pts(i + 1).Y + pts(i).Y) / 2 
                                    Next i 
                                    ' Return the result. 
                                    Return Math.Abs(area) 
                        End Function 
 
Sample: 
 
 
Video: 
 
 
Regards, 
 
Naganathan K G 
 



AL Allen February 1, 2018 08:37 AM UTC

Thanks Naganathan, very helpful


NG Naganathan Ganesh Babu Syncfusion Team February 2, 2018 04:40 AM UTC

Hi Allen,

Thanks for your update.
 

We are happy to hear that your problem is resolved. Please let us know if you need any further assistance.

Regards,
 

Naganathan K G
 
 


Loader.
Up arrow icon