I have a class Vector (representing a 3D Vector). I want to normalize that Vector (to give it a length of 1). From the three possibilities below (or feel free to suggest your own) what would you guys choose?
1. Normalize function that modifies the object:
2. Normalize function that returns a modified version of the object leaving the original object untouched.
3. Do both, modify the original and return that instance.
The question arises as I want to compare two vectors but I want to try and normalize the second vector within the equality operation:
I like option 1 as it is simple when just normalizing a vector but stumps me for the problem above.
1. Normalize function that modifies the object:
Code:
public void Normalize()
Code:
public Vector Normalize()
Code:
public Vector Normalize()
Code:
v1 == v2.Normalize()
Comment