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
파일: EdgeShape.cs 프로젝트: ajmaya/box2dx
		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