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 |
| |
vec2 | operator+ (float s) const |
| |
vec2 | operator- (const vec2 &p2) const |
| |
vec2 | operator- (float s) const |
| |
vec2 | operator* (float s) const |
multiply by a scalar operator More... | |
vec2 | operator/ (float s) const |
divide by a scalar operator More... | |
vec2 & | operator+= (const vec2 &p) |
internal + More... | |
vec2 & | operator+= (float s) |
internal + More... | |
vec2 & | operator-= (const vec2 &p) |
internal - More... | |
vec2 & | operator-= (float s) |
internal - More... | |
vec2 & | operator*= (float s) |
internal * More... | |
vec2 & | operator/= (float s) |
internal / More... | |
vec2 | operator- () const |
unary negation More... | |
vec2 | product_compontentwise (const vec2 &p) const |
does componentwise mutliplication More... | |
vec2 & | product_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... | |
Vectors/Points 2D.
cpe::vec2::vec2 | ( | ) |
empty constructor
Referenced by operator*(), operator+(), operator-(), operator/(), and product_compontentwise().
cpe::vec2::vec2 | ( | float | x, |
float | y | ||
) |
direct constructor
|
private |
assert that a size_t belongs to [[0,1]]
References MACRO_EXCEPTION_PARAMETER.
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().
float cpe::vec2::norm | ( | ) | const |
get the norm of the vector
References norm2().
Referenced by normalized().
float cpe::vec2::norm2 | ( | ) | const |
vec2 cpe::vec2::normalized | ( | ) | const |
normalize the vector to unit length
References MACRO_EXCEPTION_PARAMETER, and norm().
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 |
vec2 & cpe::vec2::operator*= | ( | float | s | ) |
internal *
References internal_x, and internal_y.
vec2 cpe::vec2::operator+ | ( | float | s | ) | const |
internal +
References internal_x, internal_y, x(), and y().
vec2 & cpe::vec2::operator+= | ( | float | s | ) |
internal +
References internal_x, and internal_y.
vec2 cpe::vec2::operator- | ( | float | s | ) | const |
vec2 cpe::vec2::operator- | ( | ) | const |
unary negation
References internal_x, internal_y, and vec2().
internal -
References internal_x, internal_y, x(), and y().
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 MACRO_EXCEPTION_PARAMETER, vec2(), x(), and y().
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, internal_y, and MACRO_EXCEPTION_PARAMETER.
float & cpe::vec2::operator[] | ( | const size_t & | k | ) |
Access to the k_th entry (k in [0,1])
References assert_size(), internal_x, internal_y, and MACRO_EXCEPTION_PARAMETER.
const float * cpe::vec2::pointer | ( | ) | const |
does componentwise mutliplication
References internal_x, internal_y, vec2(), x(), and y().
does componentwise mutliplication
perform p=(p.x()*p2.x(),p.y()*p2.x())
References internal_x, internal_y, x(), and y().
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 | ( | ) | const |
get x coordinate
References internal_x.
Referenced by dot(), cpe::mesh_io::load_obj_file(), cpe::matrix2::operator*(), operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), and product_compontentwise_internal().
float & cpe::vec2::x | ( | ) |
get x coordinate
References internal_x.
float cpe::vec2::y | ( | ) | const |
get y coordinate
References internal_y.
Referenced by dot(), cpe::mesh_io::load_obj_file(), cpe::matrix2::operator*(), operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), and product_compontentwise_internal().
float & cpe::vec2::y | ( | ) |
get y coordinate
References internal_y.
|
private |
x coordinate
Referenced by dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), pointer(), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), and x().
|
private |
y coordinate
Referenced by dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), and y().