A point is position in space. In a 3-dimensional world, a point is usually 3-tuple of
Differentiating Points and Vectors
A graphics API may choose to distinguish between a
vector class. Although the structures are both 3-tuples of the same layout and members, their usage can vary. For example, interpolating between two points and interpolating between two vectors often requires different algorithms to result in smooth, natural looking interpolation. Likewise, transforming a point versus a normal vector at that point (both 3-tuples) by a transformation matrix requires different algorithms. Differentiating the types in the compiler can help prevent inadvertent misuse of the algorithms.
On the other hand, additional classes and differentiation can add complexity and detail that is not strictly necessary to the system.
- subtract(pt, pt) -> vector
- distance(pt, pt) -> scalar
- distanceSquared(pt, pt) -> scalar - often useful when relative distances between points are being compared. This will save needing an additional square root operation on each distance calculation.
- interpolateLinear(pt, pt, t) -> pt
- interpolateSinusoidal(pt, pt, t) -> pt
- add(pt, pt) -> pt - if the system makes a distinction between points (positions) and vectors (directed lengths), then adding two points should not be part of the system - or should require additional syntactical work to ensure the programmer is not accidentally mixing unintended quantities.
Even in a 3D world, there are many instances were a 2D position is meaningful: for example, the coordinate on a the surface of a 3-dimensional object can be represented by a 2D point.
A point may be represented by a 4-tuple with a
w component as well. Useful for clip space / perpsective projection, etc. to be completed.