Box2DX.Common.Vec2.Normalize C# (CSharp) Метод

Normalize() публичный Метод

Convert this vector into a unit vector. Returns the length.
public Normalize ( ) : float
Результат float
        public float Normalize()
        {
            float length = Length();
            if (length < Math.FLOAT32_EPSILON)
            {
                return 0.0f;
            }
            float invLength = 1.0f / length;
            X *= invLength;
            Y *= invLength;

            return length;
        }

Usage Example

Пример #1
0
		public void Set(Vec2 v1, Vec2 v2)
		{
			_v1 = v1;
			_v2 = v2;

			_direction = _v2 - _v1;
			_length = _direction.Normalize();
			_normal = Vec2.Cross(_direction, 1.0f);

			_cornerDir1 = _normal;
			_cornerDir2 = -1.0f * _normal;
		}
All Usage Examples Of Box2DX.Common.Vec2::Normalize