I’m writing some 3D math classes for Python. I’d like to make a Point3 class that is separate from Vec3 in the following respects:
Point3 – Point3 = Vec3
Point3 + Vec3 = Point3
Otherwise, all operations on Vec3 you can perform on Point3. The motivation for this is to separate the mathematical concept of a point from a vector, hopefully leading to clearer type separation and an easier to understand API.
However, with Python’s duck typing and the common practice of expecting a certain interface regardless of type, is it better just to use a Vec3? Is it more efficient?
It seems superfluous. If you think about it, a point in cartesian space is entirely equivalent to a bound vector which begins at the origin. Sounds like you could be making a lot of work for yourself for nothing.