Vectors/Points 3D. More...
Public Member Functions | |
vec3 () | |
empty constructor More... | |
vec3 (float x, float y, float z) | |
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 | z () const |
get z coordinate More... | |
float & | z () |
get z coordinate More... | |
float | operator[] (const size_t &k) const |
Access to the k_th entry (k in [0,2]) More... | |
float & | operator[] (const size_t &k) |
Access to the k_th entry (k in [0,2]) More... | |
float | operator() (const size_t &k) const |
Access to the k_th entry (k in [0,2]) More... | |
float & | operator() (const size_t &k) |
Access to the k_th entry (k in [0,2]) More... | |
void | set_zero () |
set every entry to 0 More... | |
const float * | pointer () const |
fast pointer access More... | |
vec2 | to_vec2 () const |
convert to v2 (x,y) More... | |
float | dot (const vec3 &p) const |
perform dot product between two v3 More... | |
float | norm () const |
get the norm of the vector More... | |
float | norm2 () const |
get the square norm of the vector More... | |
vec3 | normalized () const |
normalize the vector to unit length More... | |
vec3 | cross (const vec3 &p) const |
compute cross product with an other vector More... | |
vec3 | operator+ (const vec3 &p2) const |
| |
vec3 | operator+ (float s) const |
| |
vec3 | operator- (const vec3 &p2) const |
| |
vec3 | operator- (float s) const |
| |
vec3 | operator* (float s) const |
multiply by a scalar operator More... | |
vec3 | operator/ (float s) const |
divide by a scalar operator More... | |
vec3 & | operator+= (const vec3 &p) |
internal + More... | |
vec3 & | operator+= (float s) |
internal + More... | |
vec3 & | operator-= (const vec3 &p) |
internal - More... | |
vec3 & | operator-= (float s) |
internal - More... | |
vec3 & | operator*= (float s) |
internal * More... | |
vec3 & | operator/= (float s) |
internal / More... | |
vec3 | operator- () const |
unary negation More... | |
vec3 | product_compontentwise (const vec3 &p) const |
does componentwise mutliplication More... | |
vec3 & | product_compontentwise_internal (const vec3 &p) |
does componentwise mutliplication More... | |
void | scale (float sx, float sy, float sz) |
internal scaling (similar to componentwise) More... | |
std::string | to_string () const |
export the value as string cout<<v3(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,2]] More... | |
Private Attributes | |
float | internal_x |
x coordinate More... | |
float | internal_y |
y coordinate More... | |
float | internal_z |
z coordinate More... | |
Vectors/Points 3D.
cpe::vec3::vec3 | ( | ) |
empty constructor
Referenced by cross(), operator+(), operator-(), operator/(), and product_compontentwise().
cpe::vec3::vec3 | ( | float | x, |
float | y, | ||
float | z | ||
) |
direct constructor
|
private |
assert that a size_t belongs to [[0,2]]
Referenced by operator[]().
compute cross product with an other vector
References internal_x, internal_y, internal_z, vec3(), x(), y(), and z().
Referenced by cpe::matrix4::projection_look_at(), and cpe::screen_position().
float cpe::vec3::dot | ( | const vec3 & | p | ) | const |
perform dot product between two v3
References internal_x, internal_y, internal_z, x(), y(), and z().
Referenced by cpe::plane::intersect(), cpe::sphere::intersect(), and cpe::reflected_direction().
float cpe::vec3::norm | ( | ) | const |
get the norm of the vector
References norm2().
Referenced by normalized().
float cpe::vec3::norm2 | ( | ) | const |
get the square norm of the vector
References internal_x, internal_y, and internal_z.
Referenced by norm(), cpe::ray::ray(), and cpe::reflected_direction().
vec3 cpe::vec3::normalized | ( | ) | const |
normalize the vector to unit length
References norm().
Referenced by cpe::quaternion::axis(), cpe::mesh::get_normal_per_vertex(), cpe::plane::intersect(), cpe::quaternion::quaternion(), cpe::ray::ray(), cpe::matrix3::rotation(), cpe::matrix4::rotation(), and cpe::screen_position().
float cpe::vec3::operator() | ( | const size_t & | k | ) | const |
Access to the k_th entry (k in [0,2])
float & cpe::vec3::operator() | ( | const size_t & | k | ) |
Access to the k_th entry (k in [0,2])
vec3 cpe::vec3::operator* | ( | float | s | ) | const |
multiply by a scalar operator
vec3 & cpe::vec3::operator*= | ( | float | s | ) |
internal *
References internal_x, internal_y, and internal_z.
vec3 cpe::vec3::operator+ | ( | float | s | ) | const |
internal +
References internal_x, internal_y, internal_z, x(), y(), and z().
vec3 & cpe::vec3::operator+= | ( | float | s | ) |
internal +
References internal_x, internal_y, and internal_z.
vec3 cpe::vec3::operator- | ( | float | s | ) | const |
vec3 cpe::vec3::operator- | ( | ) | const |
unary negation
References internal_x, internal_y, internal_z, and vec3().
internal -
References internal_x, internal_y, internal_z, x(), y(), and z().
vec3 & cpe::vec3::operator-= | ( | float | s | ) |
internal -
References internal_x, internal_y, and internal_z.
vec3 cpe::vec3::operator/ | ( | float | s | ) | const |
vec3 & cpe::vec3::operator/= | ( | float | s | ) |
internal /
References internal_x, internal_y, and internal_z.
float cpe::vec3::operator[] | ( | const size_t & | k | ) | const |
Access to the k_th entry (k in [0,2])
References assert_size(), internal_x, internal_y, and internal_z.
float & cpe::vec3::operator[] | ( | const size_t & | k | ) |
Access to the k_th entry (k in [0,2])
References assert_size(), internal_x, internal_y, and internal_z.
const float * cpe::vec3::pointer | ( | ) | const |
does componentwise mutliplication
References internal_x, internal_y, internal_z, vec3(), x(), y(), and z().
does componentwise mutliplication
perform p=(p.x()*p2.x(),p.y()*p2.x())
References internal_x, internal_y, internal_z, x(), y(), and z().
void cpe::vec3::scale | ( | float | sx, |
float | sy, | ||
float | sz | ||
) |
internal scaling (similar to componentwise)
References internal_x, internal_y, and internal_z.
void cpe::vec3::set_zero | ( | ) |
set every entry to 0
References internal_x, internal_y, and internal_z.
std::string cpe::vec3::to_string | ( | ) | const |
export the value as string cout<<v3(2,3,6) => 2 3 6
References internal_x, internal_y, and internal_z.
Referenced by cpe::operator<<().
vec2 cpe::vec3::to_vec2 | ( | ) | const |
convert to v2 (x,y)
References internal_x, and internal_y.
float cpe::vec3::x | ( | ) | const |
get x coordinate
References internal_x.
Referenced by cpe::mesh::auto_scale(), cross(), dot(), cpe::mesh::fill_color_normal(), cpe::mesh::fill_color_xyz(), cpe::plane::intersect(), cpe::mesh_io::load_obj_file(), cpe::mesh_io::load_off_file(), cpe::quaternion::operator*(), cpe::matrix3::operator*(), cpe::matrix4::operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), product_compontentwise_internal(), cpe::matrix4::projection_look_at(), cpe::quaternion::rotate(), cpe::matrix4::transformation(), cpe::matrix4::translate_internal(), and cpe::matrix4::translation().
float & cpe::vec3::x | ( | ) |
get x coordinate
References internal_x.
float cpe::vec3::y | ( | ) | const |
get y coordinate
References internal_y.
Referenced by cpe::mesh::auto_scale(), cross(), dot(), cpe::mesh::fill_color_normal(), cpe::mesh::fill_color_xyz(), cpe::plane::intersect(), cpe::mesh_io::load_obj_file(), cpe::mesh_io::load_off_file(), cpe::quaternion::operator*(), cpe::matrix3::operator*(), cpe::matrix4::operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), product_compontentwise_internal(), cpe::matrix4::projection_look_at(), cpe::quaternion::rotate(), cpe::matrix4::transformation(), cpe::matrix4::translate_internal(), and cpe::matrix4::translation().
float & cpe::vec3::y | ( | ) |
get y coordinate
References internal_y.
float cpe::vec3::z | ( | ) | const |
get z coordinate
References internal_z.
Referenced by cpe::mesh::auto_scale(), cross(), dot(), cpe::mesh::fill_color_normal(), cpe::mesh::fill_color_xyz(), cpe::plane::intersect(), cpe::mesh_io::load_obj_file(), cpe::mesh_io::load_off_file(), cpe::quaternion::operator*(), cpe::matrix3::operator*(), cpe::matrix4::operator*(), cpe::operator*(), operator+(), cpe::operator+(), operator+=(), operator-(), cpe::operator-(), operator-=(), operator/(), product_compontentwise(), product_compontentwise_internal(), cpe::matrix4::projection_look_at(), cpe::quaternion::rotate(), cpe::matrix4::transformation(), cpe::matrix4::translate_internal(), and cpe::matrix4::translation().
float & cpe::vec3::z | ( | ) |
get z coordinate
References internal_z.
|
private |
x coordinate
Referenced by cross(), dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), pointer(), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), to_vec2(), and x().
|
private |
y coordinate
Referenced by cross(), dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), to_vec2(), and y().
|
private |
z coordinate
Referenced by cross(), dot(), norm2(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), scale(), set_zero(), to_string(), and z().