Hi Everyone

I’ve been trying to make a script that would take a mesh of cross section and then calculate basic properties like second moment of area(geometric moment of inertia), torsional constant and area. I tried few methods of achieving the results but outputs are quiet inconsistent with expected values that should be returned.

So at first I’ve tried to use SciPy to achieve this and just integrate with dblquad function but the outputs sometimes became not moment of area but area ofr i wasn’t quite sure what caused that but i deem that on my poor understanding of integration.

My current approach is way more error prone than integration but the results are closer to the expected ones, although Im kind of lost since its working only in the case of certain figures and some return values that look like it was elevated to some certain power.

For e.g. circle with radius of 1 returns value of around 0.59 which is close enough to square of the expected value of 0,78.

While square with base of 2 returns 1.325 which is close enough to expected value of 1.333

Same goes with triangle(with all sides equal) that also returns almost precise values

So here’s the code

```
import bpy
import bmesh
from mathutils import Vector
import numpy as np
import scipy as sp
import os
obj = bpy.context.object
vertsx = [v for v in obj.data.vertices]
vertsy = [v for v in obj.data.vertices]
#calculation of area
center_of_mesh = Vector()
bm = bmesh.new()
bm.from_mesh(obj.data)
for face in bm.faces:
center_of_mesh += face.calc_center_median()
center_of_mesh/len(bm.faces)
area = sum(f.calc_area() for f in bm.faces)
bm.free()
#clear the console
os.system('cls')
print("center of mesh = {}".format(center_of_mesh.xy))
print("area = ", area)
#calculation of second moment of area
ix = []
iy = []
for v in obj.data.vertices:
ix.append(abs(center_of_mesh.x-v.co.x)) #this loop should return estimate area
iy.append(abs(v.co.y - center_of_mesh.y))
for v in obj.data.vertices:
ix.append(abs(center_of_mesh.x-v.co.x)) #this loop should return estimate of first moment of area
iy.append(abs(v.co.y - center_of_mesh.y))
for v in obj.data.vertices:
ix.append(abs(center_of_mesh.x-v.co.x)) #this loop should return estimate of first moment of area
iy.append(abs(v.co.y - center_of_mesh.y))
#averaging out the value
ixx = ((sum(ix)/len(obj.data.vertices))/len(obj.data.vertices))/len(obj.data.vertices)
iyy = (((sum(iy)/len(obj.data.vertices))/len(obj.data.vertices))/len(obj.data.vertices))
#printing out values
print("ixx = ", ixx)
print("iyy = ", iyy)
```

The method itself is quite inefficient and im aware of that but its simple enough and seems to be working to some degree and im wondering what cause the inconsistence with the outputs. I would like to use it for more complicated shapes and id love to hear anyone’s idea how to fix that up i spend quite some time doing that by try and error but i find no clues what may be causing this