Py2D icon indicating copy to clipboard operation
Py2D copied to clipboard

Divide by Zero prevention

Open Canonelis opened this issue 2 years ago • 0 comments

/Math/Operations.py line 285

r = float(ap * ab) / ab.length_squared

could be changed to

r = float(ap * ab) / (1 if ab.length_squared == 0 else ab.length_squared)

Then anytime ab.length_squared is of length 0, that means float(ap * ab) is 0, which means r is 0, which means the function will return ap.length_squared

Canonelis avatar Jul 04 '22 18:07 Canonelis