cpe::vec2 Class Reference

Vectors/Points 2D. More...

Public Member Functions

 vec2 ()
 empty constructor More...
 
 vec2 (float x, float y)
 direct constructor More...
 
float x () const
 get x coordinate More...
 
float & x ()
 get x coordinate More...
 
float y () const
 get y coordinate More...
 
float & y ()
 get y coordinate More...
 
float operator[] (const size_t &k) const
 Access to the k_th entry (k in [0,1]) More...
 
float & operator[] (const size_t &k)
 Access to the k_th entry (k in [0,1]) More...
 
float operator() (const size_t &k) const
 Access to the k_th entry (k in [0,1]) More...
 
float & operator() (const size_t &k)
 Access to the k_th entry (k in [0,1]) More...
 
void set_zero ()
 set every entry to 0 More...
 
const float * pointer () const
 fast pointer access More...
 
float dot (const vec2 &p) const
 perform dot product between two v2 More...
 
float norm () const
 get the norm of the vector More...
 
float norm2 () const
 get the square norm of the vector More...
 
vec2 normalized () const
 normalize the vector to unit length More...
 
vec2 operator+ (const vec2 &p2) const
 
  • operator
More...
 
vec2 operator+ (float s) const
 
  • operator
More...
 
vec2 operator- (const vec2 &p2) const
 
  • operator
More...
 
vec2 operator- (float s) const
 
  • operator
More...
 
vec2 operator* (float s) const
 multiply by a scalar operator More...
 
vec2 operator/ (float s) const
 divide by a scalar operator More...
 
vec2operator+= (const vec2 &p)
 internal + More...
 
vec2operator+= (float s)
 internal + More...
 
vec2operator-= (const vec2 &p)
 internal - More...
 
vec2operator-= (float s)
 internal - More...
 
vec2operator*= (float s)
 internal * More...
 
vec2operator/= (float s)
 internal / More...
 
vec2 operator- () const
 unary negation More...
 
vec2 product_compontentwise (const vec2 &p) const
 does componentwise mutliplication More...
 
vec2product_compontentwise_internal (const vec2 &p)
 does componentwise mutliplication More...
 
void scale (float sx, float sy)
 internal scaling (similar to componentwise) More...
 
std::string to_string () const
 export the value as string cout<<v2(2,3,6) => 2 3 6 More...
 

Private Member Functions

void assert_size (const size_t &k) const
 assert that a size_t belongs to [[0,1]] More...
 

Private Attributes

float internal_x
 x coordinate More...
 
float internal_y
 y coordinate More...
 

Detailed Description

Vectors/Points 2D.

Constructor & Destructor Documentation

cpe::vec2::vec2 ( )

empty constructor

Referenced by operator*(), operator+(), operator-(), operator/(), and product_compontentwise().

cpe::vec2::vec2 ( float  x,
float  y 
)

direct constructor

Member Function Documentation

void cpe::vec2::assert_size ( const size_t &  k) const
private

assert that a size_t belongs to [[0,1]]

Referenced by operator[]().

float cpe::vec2::dot ( const vec2 p) const

perform dot product between two v2

References internal_x, internal_y, x(), and y().

+ Here is the call graph for this function:

float cpe::vec2::norm ( ) const

get the norm of the vector

References norm2().

Referenced by normalized().

+ Here is the call graph for this function:

float cpe::vec2::norm2 ( ) const

get the square norm of the vector

References internal_x, and internal_y.

Referenced by norm().

vec2 cpe::vec2::normalized ( ) const

normalize the vector to unit length

References norm().

+ Here is the call graph for this function:

float cpe::vec2::operator() ( const size_t &  k) const

Access to the k_th entry (k in [0,1])

float & cpe::vec2::operator() ( const size_t &  k)

Access to the k_th entry (k in [0,1])

vec2 cpe::vec2::operator* ( float  s) const

multiply by a scalar operator

References vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 & cpe::vec2::operator*= ( float  s)

internal *

References internal_x, and internal_y.

vec2 cpe::vec2::operator+ ( const vec2 p2) const

  • operator

References vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 cpe::vec2::operator+ ( float  s) const

  • operator

vec2 & cpe::vec2::operator+= ( const vec2 p)

internal +

References internal_x, internal_y, x(), and y().

+ Here is the call graph for this function:

vec2 & cpe::vec2::operator+= ( float  s)

internal +

References internal_x, and internal_y.

vec2 cpe::vec2::operator- ( const vec2 p2) const

  • operator

References vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 cpe::vec2::operator- ( float  s) const

  • operator

References vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 cpe::vec2::operator- ( ) const

unary negation

References internal_x, internal_y, and vec2().

+ Here is the call graph for this function:

vec2 & cpe::vec2::operator-= ( const vec2 p)

internal -

References internal_x, internal_y, x(), and y().

+ Here is the call graph for this function:

vec2 & cpe::vec2::operator-= ( float  s)

internal -

References internal_x, and internal_y.

vec2 cpe::vec2::operator/ ( float  s) const

divide by a scalar operator

References vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 & cpe::vec2::operator/= ( float  s)

internal /

References internal_x, and internal_y.

float cpe::vec2::operator[] ( const size_t &  k) const

Access to the k_th entry (k in [0,1])

References assert_size(), internal_x, and internal_y.

+ Here is the call graph for this function:

float & cpe::vec2::operator[] ( const size_t &  k)

Access to the k_th entry (k in [0,1])

References assert_size(), internal_x, and internal_y.

+ Here is the call graph for this function:

const float * cpe::vec2::pointer ( ) const

fast pointer access

Warning
unprotected access

References internal_x.

vec2 cpe::vec2::product_compontentwise ( const vec2 p) const

does componentwise mutliplication

Returns
MC_v2d(x*p.x(),y*p.y(),z*p.z())

References internal_x, internal_y, vec2(), x(), and y().

+ Here is the call graph for this function:

vec2 & cpe::vec2::product_compontentwise_internal ( const vec2 p)

does componentwise mutliplication

perform p=(p.x()*p2.x(),p.y()*p2.x())

References internal_x, internal_y, x(), and y().

+ Here is the call graph for this function:

void cpe::vec2::scale ( float  sx,
float  sy 
)

internal scaling (similar to componentwise)

References internal_x, and internal_y.

void cpe::vec2::set_zero ( )

set every entry to 0

References internal_x, and internal_y.

std::string cpe::vec2::to_string ( ) const

export the value as string cout<<v2(2,3,6) => 2 3 6

References internal_x, and internal_y.

Referenced by cpe::operator<<().

float & cpe::vec2::x ( )

get x coordinate

References internal_x.

float & cpe::vec2::y ( )

get y coordinate

References internal_y.

Member Data Documentation


The documentation for this class was generated from the following files: