File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -214,10 +214,20 @@ impl Plane {
214
214
self . normal . dot ( point) > self . d
215
215
}
216
216
217
- /// Returns a normalized copy of the plane.
217
+ /// Returns a copy of the plane with its `normal` and `d` scaled to the unit length.
218
+ ///
219
+ /// A `normal` length of `0.0` would return a plane with its `normal` and `d` being `Vector3::ZERO`
220
+ /// and `0.0` respectively.
218
221
#[ inline]
219
222
pub fn normalized ( self ) -> Self {
220
- Plane :: new ( self . normal . normalized ( ) , self . d )
223
+ let length: real = self . normal . length ( ) ;
224
+ if length == 0.0 {
225
+ return Plane {
226
+ normal : Vector3 :: ZERO ,
227
+ d : 0.0 ,
228
+ } ;
229
+ }
230
+ Plane :: new ( self . normal . normalized ( ) , self . d / length)
221
231
}
222
232
223
233
/// Returns the orthogonal projection of `point` to the plane.
You can’t perform that action at this time.
0 commit comments