Core 1.0
Vector4 Class Reference

Vectors in four dimensions. More...

#include <evector4.h>

Public Member Functions

 Vector4 ()
 Empty.
 Vector4 (const double &, const double &, const double &, const double &)
 Create a vector given its four coordinates.
constexpr double & operator[] (int)
 Access to a component.
constexpr double operator[] (int) const
 Access to a component.
Vector4 operator- () const
 Overloaded.
QString ToGLSL () const
 Return QString of the form 'vec4(x, y, z, w)' that write the vector in GLSL.

Protected Attributes

double c [4] = { 0.0, 0.0, 0.0, 0.0 }
 Components.

Friends

Vector4 operator+ (const Vector4 &u, const Vector4 &v)
 Overloaded.
Vector4 operator- (const Vector4 &u, const Vector4 &v)
 Overloaded.
double operator* (const Vector4 &u, const Vector4 &v)
 Compute the dot product of two vectors.
Vector4 operator* (const Vector4 &u, const double &a)
 Right multiply a vector by a scalar.
Vector4 operator* (const double &a, const Vector4 &u)
 Left multiply a vector by a scalar.
Vector4 operator/ (const Vector4 &u, const double &a)
 Divide a vector by a scalar.
Vector4 Sin (const Vector4 &u)
 Compute the sine of each component.
std::ostream & operator<< (std::ostream &s, const Vector4 &u)
 Overloaded output-stream operator.

Detailed Description

Vectors in four dimensions.

This class is a simple container of four real components, used for linear algebra in \( R^4 \) (see Matrix4::operator*(const Vector4&)). It is not a homogeneous point: no division by the last component is ever performed.

Member Function Documentation

◆ operator[]() [1/2]

double & Vector4::operator[] ( int i)
inlineconstexpr

Access to a component.

Parameters
iIndex, in [0,3].

◆ operator[]() [2/2]

double Vector4::operator[] ( int i) const
inlineconstexpr

Access to a component.

Parameters
iIndex, in [0,3].

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Vector4 & u )
friend

Overloaded output-stream operator.

Parameters
uVector.
sStream.