Andos's picture

Request for a quick Vector.Normalized property

Very often I just need a normalized version of my vector that I know isn't zero-length.
Before I migrated to OpenTK I was using a LinearMath library that had a nifty little .Normalized property that simply just returned a copy of the vector but normalized.
Otherwise I manually have to create a copy, normalize it and use it. It takes two more lines and clutters the code.

For OpenTK you could add .Normalized and .NormalizedFast

What do you think? It is very quick and easy to add.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
martinsm's picture

You can always use static methods:

Vector4 v = new Vector4(x,y,z,w);
Vector4 v1 =  Vector4.Normalize(v);
Vector4 v2 =  Vector4.NormalizeFast(v);
Andos's picture

Didn't notice those :)