Library/Graphics/Points

Overview
A point is position in space. In a 3-dimensional world, a point is usually 3-tuple of, , and coordinates.

Differentiating Points and Vectors
A graphics API may choose to distinguish between a and  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.

Functions

 * 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

Extended Functions

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

2D points
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.

4-tuples
A point may be represented by a 4-tuple with a component as well. Useful for clip space / perpsective projection, etc..