|
CGVIS Utils
|
2D vector template with arithmetic, length utilities, and helpers. More...
#include <ostream>#include <string>#include <array>#include <sstream>#include <cmath>#include "Rand.h"Go to the source code of this file.
Classes | |
| union | Vec2t< T > |
Typedefs | |
| typedef Vec2t< float > | Vec2 |
| Float vector (x,y). | |
| typedef Vec2t< int32_t > | Vec2i |
| 32-bit signed integer vector (x,y). | |
| typedef Vec2t< uint32_t > | Vec2ui |
| 32-bit unsigned integer vector (x,y). | |
Functions | |
| template<typename T> | |
| std::ostream & | operator<< (std::ostream &os, const Vec2t< T > &v) |
| Stream insertion for string representation of a vector. | |
| template<typename T> | |
| Vec2t< T > | operator* (float scalar, const Vec2t< T > &vec) |
| Scalar multiplication with scalar on the left. | |
2D vector template with arithmetic, length utilities, and helpers.
This header defines a simple 2D vector type template, Vec2t<T>, that stores two components and exposes multiple alias views (x/y and r/g). It provides basic arithmetic operators, scalar operations, length helpers, and a few convenience utilities (random generation, normalization, clamping) suitable for lightweight math and graphics code.
union with multiple member layouts (an std::array and two structs for aliases). This is intentionally done for ergonomic access (e.g., v.x vs. v.e[0]). Scalar multiplication with scalar on the left.
| T | Component type of vector. |
| scalar | Scalar factor. |
| vec | Vector to multiply. |
| std::ostream & operator<< | ( | std::ostream & | os, |
| const Vec2t< T > & | v ) |
Stream insertion for string representation of a vector.
| T | Component type. |
| os | Output stream. |
| v | Vector to print. |