Struct Point

Struct Documentation

struct Point

A point in (time, value) space.

A Point is the fundamental coordinate type of the library. Its two components are named time (the horizontal axis of an animation curve) and value (the vertical axis). The same type doubles as a 2D vector for direction and displacement math; see the Vector alias.

Public Functions

inline Point(double time = 0.0, double value = 0.0)

Constructs a point, defaulting to the origin (0, 0).

Parameters:
  • time – Time component.

  • value – Value component.

inline Point operator+(const Point &other) const

Component-wise addition.

inline Point operator-(const Point &other) const

Component-wise subtraction.

inline Point operator*(double scalar) const

Scales both components by scalar.

inline Point operator/(double scalar) const

Divides both components by scalar.

Parameters:

scalar – Divisor.

Throws:

std::domain_error – if scalar is zero.

Returns:

The scaled point.

inline bool operator==(const Point &other) const

Exact (bit-for-bit) equality of both components.

inline bool operator!=(const Point &other) const

Negation of operator==.

inline Point &operator+=(const Point &other)

Component-wise compound addition.

inline Point &operator-=(const Point &other)

Component-wise compound subtraction.

inline Point &operator*=(double scalar)

Compound scale by scalar.

inline Point &operator/=(double scalar)

Compound divide by scalar.

Parameters:

scalar – Divisor.

Throws:

std::domain_error – if scalar is zero.

Returns:

Reference to this point after scaling.

inline bool is_zero() const

Returns true if both components are exactly zero.

inline void reset()

Resets both components to zero.

inline void set(double new_time, double new_value)

Sets both components in one call.

Public Members

double time

Position along the time (horizontal) axis.

double value

Position along the value (vertical) axis.