Closed smoothumut closed 4 months ago
Hi Marco, problem is about if the pts[1] and pts[2] looks to the same direction, then it cannot find the normal so I changed the code, I know it is not the best, but it may help
@property
def normal(self) -> np.ndarray:
pts = self.vertices
p0, p1 = pts[0], pts[1]
for pt in pts[2:]:
AB = p1 - p0
AC = pt - p0
cosine_angle = np.dot(AB, AC) / (np.linalg.norm(AB) * np.linalg.norm(AC))
angle_in_degrees = np.arccos(cosine_angle) * (180.0 / np.pi)
if angle_in_degrees > 5 and angle_in_degrees < 175:
normal = np.cross(AB, AC)
normal = normal / np.linalg.norm(normal)
return normal
Thanks Umut! Just pushed a fix by modifying a bit your suggestion which was already pretty good.
Frankly, Thank you Marco for this great work! 🙇
Hi Marco, Hope everything is great with you. I try to get normal of the newly created Plane, but when I try to get the normal of the plane, strangly it gives different normal even the code looks good
In my actual code, it gives totally different plane normal even it draws it correctly here the Plane class with the latest vedo version I try to use
Am I missing something?? thanks in advance Best Regards Umut