Center of Mass (surface) with bmesh (edit mode)

following this troymcconaghy.com/2015/06/25/how-blender-calculates-center-of-mass/ I’m trying to find center of mass (surface) of an object. I’m doing
loc = sum(([email protected]_center_median_weighted() for f in bm.faces), Vector())/(len(bm.faces))
but this is not exactly this(referring to origin to center of mass(vol)). any idea?

ok I found some complementary information, not with bmesh and using triangles

and this

some maths around this

well problem if the origin has been moved