Public Overrides Function GetArea() As Single Return Math.Sqrt(ShapeWidth * ShapeHeight) End Function
Why do I need to apply the square root?
Public Overrides Function GetArea() As Single Return Math.Sqrt(ShapeWidth * ShapeHeight) End Function
Public Function Distance(ByVal Point1 As PointF, ByVal Point2 As PointF) As Single Dim dx As Single = Point1.X - Point2.X Dim dy As Single = Point1.Y - Point2.Y Return Math.Sqrt(dx * dx + dy * dy) End Function
Quote:Original post by Magpie
OK the Area of a 4 sided figure, Square or Rectangle is Width * height.
If you are using coordinates you need to calculate the distance of the width and the height.
IE:
Width will be W = Sqrt((X2-X1)^2 + (Y2-Y1)^2)
Height will be H = Sqrt((X3-X1)^2 + (Y3-Y1)^2)
So area is W * H
OR
Sqrt((X2-X1)^2 + (Y2-Y1)^2) * Sqrt((X3-X1)^2 + (Y3-Y1)^2)
Quote:A more robust method that will work for any closed figure is to calculate by sum of latitudes and departures : http://www.wikihow.com/Calculate-the-Area-of-a-Polygon
Quote:Original post by Magpie
OK the Area of a 4 sided figure, Square or Rectangle is Width * height.
If you are using coordinates you need to calculate the distance of the width and the height.
IE:
Width will be W = Sqrt((X2-X1)^2 + (Y2-Y1)^2)
Height will be H = Sqrt((X3-X1)^2 + (Y3-Y1)^2)
So area is W * H