====== Tuple2 ====== ===== Description ===== tTuple2.h provides a 2 element tuple represented by a user-provided type, which is commonly a floating or fixed point type. The type is immutable, meaning that once constructed, no methods modify the members. ===== Methods ===== Trivial operations are provided via operator overloading. ^ Operation ^ Math ^ | Negation | vec{a} = -vec{b} | | Subtraction | vec{a} = vec{b} - vec{c} | | Addition | vec{a} = vec{b} + vec{c} | | Scalar Multiplication | vec{a} = s vec{b}| inline const tTuple2 tTuple2::absolute() const; **absolute** returns the following: inline const tTuple2 tTuple2::clamp(T minval, T maxval) const; **clamp** ensures each component is within the range delim{[}{minval, maxval}{]} inline T tPoint2::distance(const tPoint2 &other) const; **distance** calculates the distance between two points, a and b: sqrt{(a_x - b_x)^2 + (a_y - b_y)^2} inline T tPoint2::distanceSquared(const tPoint2 &other) const; **distanceSquared** calculates the square of the distance between two points, a and b: (a_x - b_x)^2 + (a_y - b_y)^2 inline T tVector2::angle(const tVector2 &other) const; **angle** calculates the angle between two vectors(in radians): theta = cos^{-1}({a dot b}/{delim{vert}{a}{vert} delim{vert}{b}{vert}}) inline T tVector2::dot(const tVector2 &other) const; **dot** calculates the dot/inner/scalar product: a dot b = a_x b_x + a_y b_y = delim{vert}{a}{vert} delim{vert}{b}{vert} cos(theta) inline T tVector2::length() const; **length** calculates the length/magnitude of the vector: delim{vert}{a}{vert} = sqrt{{a_x}^2 + {a_y}^2} inline T tVector2::lengthSquared() const; **lengthSquared** calculates the square of the length/magnitude of the vector: {delim{vert}{a}{vert}}^2 = {a_x}^2 + {a_y}^2 inline const tVector2 tVector2::unit() const; **unit** returns the unit vector for this vector: {1/{delim{vert}{a}{vert}}}a ===== Typedefs ===== typedef tTuple2 tTuple2f; typedef tPoint2 tPoint2f; typedef tVector2 tVector2f; typedef tTexCoord2 tTexCoord2f; ===== Notes ===== * None