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.
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
How precise do you have to be?
If you really need to get into the math, then instead of the Gaussian area calculation, you can perhaps divide the plane into triangles. But that is another, more complicated solution.
If you want to avoid more complicated math, I would draw the polygon on a bitmap, paint its area, and count how many pixels are painted.
nally, the calculations I am currently performing with the code are pretty accurate.
But I need the breakdown into the specific area types because I need to show how the final result was obtained. That's why I'm looking for such a decomposition in the individual areas to output them later.
What do you mean with this : rectangle in a polygon ?
Do you want to split a polygon into 'simple' surfaces or what else ?
I suppose that 'walls' is a List.
What does it contain ?
Then you use:
Here is an example:
There is now a rectangle and a square.
Now I would like both to be found and calculated and displayed individually according to the known formulas for area calculation, to prove how the dimensions come about.
Now I would like both to be found and calculated and displayed individually according to the known formulas for area calculation, to prove how the dimensions come about
What kind of measurement program ?
How are the room surfaces defined ?
Couldn't these be directly defined with a kind of set of 'elementary' subsurfaces ?
And then you can do whatever you want.
This is what i meant with 'a kind of set of 'elementary' subsurfaces', can't those be defined during the measurement.
One rectangle, then a second one and even others.