pub fn normalize(self) -> Option<Self> {
        let square_magnitude = self.square_magnitude().sqrt();

        if square_magnitude == 0.0 {
            // cannot normalize zero vector
            None
        } else {
            Some(self * (1.0 / square_magnitude))
        }
    }
/// Returns a unit vector parallel to the current `Vector`, or `None` if this vector
/// is the unit vector.
///
/// # Examples
/// ```rust
/// # use dcc_boids::vector::Vector;
/// // Zero vector cannot be normalized
/// assert_eq!(Vector::zero().normalize(), None);
///
/// // Any other vector can
/// let v = Vector::new(5.0, 0.0);
/// assert_eq!(v.normalize(), Some(Vector::new(1.0, 0.0)));
/// ```
Returns a unit vector parallel to the current `Vector`, or `None` if this vector
is the unit vector.
Returns a unit vector parallel to the current ` Vector ` or ` None ` if this vector is the unit vector .
pub fn normalize(self) -> Option<Self> {
        let square_magnitude = self.square_magnitude().sqrt();
        if square_magnitude == 0.0 {
            // cannot normalize zero vector
            None
        } else {
            Some(self * (1.0 / square_magnitude))
        }
    }
pub fn normalize ( self ) -> Option < Self > { let square_magnitude = self . square_magnitude ( ) . sqrt ( ) ; if square_magnitude == 0.0 { // cannot normalize zero vector None } else { Some ( self * ( 1.0 / square_magnitude ) ) } }
Returns a unit vector parallel to the current `Vector`, or `None` if this vector
is the unit vector.
Returns a unit vector parallel to the current ` Vector ` or ` None ` if this vector is the unit vector .
self
self
examples
None
use dcc_boids::vector::vector;
Zero vector cannot be normalized
assert_eq!(Vector::zero().normalize(), None).


Zero vector cannot be normalized assert_eq! ( Vector :: zero () . normalize () None ) .