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).(adsbygoogle = window.adsbygoogle || []).push({});

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 doesnt 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.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Design Considerations - Simple Vector Class

**Physics Forums | Science Articles, Homework Help, Discussion**