CGVIS Utils
Loading...
Searching...
No Matches
Vec4.h File Reference

4D vector template with arithmetic, length helpers, and utilities. More...

#include <ostream>
#include <string>
#include <array>
#include "Vec2.h"
#include "Vec3.h"
Include dependency graph for Vec4.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  Vec4t< T >

Typedefs

typedef Vec4t< float > Vec4
 4D float vector (x,y,z,w).
typedef Vec4t< int32_t > Vec4i
 4D 32-bit signed integer vector (x,y,z,w).
typedef Vec4t< uint32_t > Vec4ui
 4D 32-bit unsigned integer vector (x,y,z,w).

Functions

template<typename T>
std::ostream & operator<< (std::ostream &os, const Vec4t< T > &v)
 Stream insertion for string representation of a vector.
template<typename T>
Vec4t< T > operator* (float scalar, const Vec4t< T > &vec)
 Scalar multiplication with scalar on the left.

Detailed Description

4D vector template with arithmetic, length helpers, and utilities.

Defines a compact 4D vector type template, Vec4t<T>, storing four components with multiple alias views (x/y/z/w and r/g/b/a) and sub-vectors (xy, xyz). Provides component-wise and scalar arithmetic, length helpers, dot product, normalization, clamping, and random generation.

Note
This type is implemented as a union with several member layouts to allow ergonomic access (e.g., v.x vs. v.e[0]). Access only one active view at a time.

Typedef Documentation

◆ Vec4

typedef Vec4t<float> Vec4

4D float vector (x,y,z,w).

◆ Vec4i

typedef Vec4t<int32_t> Vec4i

4D 32-bit signed integer vector (x,y,z,w).

◆ Vec4ui

typedef Vec4t<uint32_t> Vec4ui

4D 32-bit unsigned integer vector (x,y,z,w).

Function Documentation

◆ operator*()

template<typename T>
Vec4t< T > operator* ( float scalar,
const Vec4t< T > & vec )

Scalar multiplication with scalar on the left.

Template Parameters
TComponent type of vector.
Parameters
scalarScalar factor.
vecVector to multiply.
Returns
Result of vec * scalar.

◆ operator<<()

template<typename T>
std::ostream & operator<< ( std::ostream & os,
const Vec4t< T > & v )

Stream insertion for string representation of a vector.

Template Parameters
TComponent type.
Parameters
osOutput stream.
vVector to print.
Returns
Reference to the output stream.
Here is the call graph for this function: