I am trying to run a Python code using the Sympy.Geometry module in Google Colab and I am encountering an error I don't understand its cause. The code is the following:
import sympy.geometry as spg
lado = 5
p1, p2, p3, p4 = [(0, 0), (lado, 0), (lado, lado), (0, lado)]
p = spg.Polygon(p1, p2, p3, p4)
area = p.area
print(area)
cdg = p.centroid
print(cdg.x, " ", cdg.y, " ", cdg.length)
ixx, iyy, ixy = p.second_moment_of_area()
print(ixx.evalf(), " ", iyy.evalf(), " ", ixy.evalf())
The two first prints work perfectly, but for the last one I get an error indicating that " 'Polygon' object has no attribute 'second_moment_of_area' "
25
5/2 5/2 0
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-35b0f4f6740c> in <module>()
9 cdg = p.centroid
10 print(cdg.x, " ", cdg.y, " ", cdg.length)
---> 11 ixx, iyy, ixy = p.second_moment_of_area()
12 print(ixx.evalf(), " ", iyy.evalf(), " ", ixy.evalf())
AttributeError: 'Polygon' object has no attribute 'second_moment_of_area'
However, the method is on the sympy documentation (https://docs.sympy.org/latest/modules/geometry/polygons.html#sympy.geometry.polygon.Polygon) I have also noticed that when I start typing "p." and the autocomplete suggests me attributes and methods of the class, many of the documented don't appear. I have tried to run successfully the same code in JupyterLab and Visual Studio Code.
I would appreciate any help. Thanks very much.