Fix divide by zero in Matrix3D (thanks @longde123)