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; }
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; }