If I have a rectangle, a square and a trapezoid in a polygon, how is it possible to calculate and output them individually from an open shape?
Attached code how I currently calculate the base area of a room.
Attached code how I currently calculate the base area of a room.
B4X:
Sub CalculateFloorArea_orginal() As Double
If walls.Size < 3 Then
Log("Nicht genug Wände für eine Flächenberechnung")
Return 0
End If
Dim area As Double = 0
Dim n As Int = walls.Size
For i = 0 To n - 1
Dim wall1 As Map = walls.Get(i)
Dim wall2 As Map = walls.Get((i + 1) Mod n)
Dim x1 As Double = wall1.Get("x")
Dim y1 As Double = wall1.Get("y")
Dim x2 As Double = wall2.Get("x")
Dim y2 As Double = wall2.Get("y")
Dim partialArea As Double = x1 * y2 - x2 * y1
area = area + partialArea
Next
area = 0.5 * Abs(area)
Log("Berechnete Gesamtfläche: " & area)
Return area
End Sub