diff --git a/Source/OpenTK/Math/Vector2.cs b/Source/OpenTK/Math/Vector2.cs index da775bae..9ab160ee 100644 --- a/Source/OpenTK/Math/Vector2.cs +++ b/Source/OpenTK/Math/Vector2.cs @@ -187,5 +187,48 @@ namespace OpenTK.Math } #endregion + + /// + /// Returns the length of the vector. + /// + public float Length + { + get + { + return System.Math.Sqrt(this.LengthSquared); + } + } + + /// + /// Returns the square of the vector length. + /// + public float LengthSquared + { + get + { + return X * X + Y * Y; + } + } + + /// + /// Scales the Vector2 to unit length. + /// + /// The normalized version of the current vector. + public Vector2 Normalize() + { + float length = this.Length; + return new Vector2(X / length, Y / Length); + } + + /// + /// Scales the current Vector2 by the given amounts. + /// + /// The scale of the X component. + /// The scale of the Y component. + /// A new, scaled Vector2. + public Vector2 Scale(float sx, float sy) + { + return new Vector2(X * x, Y * y); + } } }