11from typing import Annotated
2+ from typing import Optional
3+ from typing import Union
24
35from compas .geometry import Frame
46from compas .geometry import Line
@@ -93,7 +95,7 @@ def __init__(self, forces=None, **kwargs):
9395
9496 self ._points2 = None
9597 self ._polygon2 = None
96- self ._forces = forces
98+ self ._forces = forces or []
9799
98100 self ._compressiondata = None
99101 self ._tensiondata = None
@@ -131,7 +133,7 @@ def M0(self) -> float:
131133 m0 = 0
132134 for a , b in pairwise (self .points2 + self .points2 [:1 ]):
133135 d = b - a
134- n = [d [1 ], - d [0 ], 0 ]
136+ n = [d [1 ], - d [0 ], 0 ] # type: ignore
135137 m0 += dot_vectors (a , n )
136138 return 0.5 * m0
137139
@@ -140,7 +142,7 @@ def M1(self) -> Point:
140142 m1 = Point (0 , 0 , 0 )
141143 for a , b in pairwise (self .points2 + self .points2 [:1 ]):
142144 d = b - a
143- n = [d [1 ], - d [0 ], 0 ]
145+ n = [d [1 ], - d [0 ], 0 ] # type: ignore
144146 m0 = dot_vectors (a , n )
145147 m1 += (a + b ) * m0
146148 return m1 / 6
@@ -150,7 +152,7 @@ def M2(self) -> Annotated[list[Annotated[list[float], 3]], 3]:
150152 m2 = outer_product ([0 , 0 , 0 ], [0 , 0 , 0 ])
151153 for a , b in pairwise (self .points2 + self .points2 [:1 ]):
152154 d = b - a
153- n = [d [1 ], - d [0 ], 0 ]
155+ n = [d [1 ], - d [0 ], 0 ] # type: ignore
154156 m0 = dot_vectors (a , n )
155157 aa = outer_product (a , a )
156158 ab = outer_product (a , b )
@@ -163,7 +165,7 @@ def M2(self) -> Annotated[list[Annotated[list[float], 3]], 3]:
163165 m0 ,
164166 ),
165167 )
166- return scale_matrix (m2 , 1 / 12.0 )
168+ return scale_matrix (m2 , 1 / 12.0 ) # type: ignore
167169
168170 @property
169171 def kern (self ):
@@ -267,7 +269,7 @@ def frictiondata(self) -> list[list[float]]:
267269 return self ._frictiondata
268270
269271 @property
270- def resultantpoint (self ) -> list [float ]:
272+ def resultantpoint (self ) -> Optional [ Union [ Point , list [float ]] ]:
271273 if not self .forces :
272274 return []
273275 normalcomponents = [f ["c_np" ] - f ["c_nn" ] for f in self .forces ]
@@ -291,7 +293,7 @@ def resultantforce(self) -> list[Line]:
291293 return [Line (p1 , p2 )]
292294
293295 @property
294- def resultantdata (self ) -> list [float ]:
296+ def resultantdata (self ) -> Optional [ list [float ] ]:
295297 if not self ._resultantdata :
296298 if self .forces :
297299 normalcomponents = [f ["c_np" ] - f ["c_nn" ] for f in self .forces ]
0 commit comments