LifeSimulation.Core.Vector.Normalize C# (CSharp) Method

Normalize() public method

public Normalize ( ) : Vector
return Vector
        public Vector Normalize()
        {
            double s = this.Norm();
            return s == 0 ? this : this / s;
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Sets a request to move the lifelet with the given velocity.
 /// </summary>
 protected void move(Vector v)
 {
     // Put a cap on vel
     double n = v.Norm();
     if(n > Config.LifeletMaximumVelocityRequest) {
         v = v.Normalize() * Config.LifeletMaximumVelocityRequest;
     }
     // Update requested velocity for next simulate
     _velReq = v;
 }