- #1
3trQN
- 337
- 1
I had a curious thought while writing a simple program that involved writing my own vector class (as in a mathematical representation of a displacement in n-dimensional space).
I was wondering which way would be best to design the vector class ( language is C++ ).
The first method was to build a vector class with functions/methods built into it for handling the required vector operations (such as the scalar/vector product and normalisation/scaling transformations). Then to also include operator overloading and polar/cartesian/other coordinate system conversions etc.
The other idea was to just to use a simple vector (possibly even a struct or the bare minimum) and have the vector maths and operations handled seperatley, as possibly global functions operating on the vectors.
The first method has advantages in that it follows OOP methods and doesn't break the encapsulation rules. It would seem to be a safer and more complete design. However it may also be restrictive in some way, in the future.
Whereas the latter method is more open.
So i was wondering, if anyone has any experience with kind of thing, could offer and insight or suggestions.
I was wondering which way would be best to design the vector class ( language is C++ ).
The first method was to build a vector class with functions/methods built into it for handling the required vector operations (such as the scalar/vector product and normalisation/scaling transformations). Then to also include operator overloading and polar/cartesian/other coordinate system conversions etc.
The other idea was to just to use a simple vector (possibly even a struct or the bare minimum) and have the vector maths and operations handled seperatley, as possibly global functions operating on the vectors.
The first method has advantages in that it follows OOP methods and doesn't break the encapsulation rules. It would seem to be a safer and more complete design. However it may also be restrictive in some way, in the future.
Whereas the latter method is more open.
So i was wondering, if anyone has any experience with kind of thing, could offer and insight or suggestions.