Vectors/Points 3D. More...
Public Member Functions | |
v3 () | |
empty constructor | |
v3 (const double &x, const double &y, const double &z) | |
direct constructor | |
const double & | x () const |
get x coordinate | |
double & | x () |
get x coordinate | |
const double & | y () const |
get y coordinate | |
double & | y () |
get y coordinate | |
const double & | z () const |
get z coordinate | |
double & | z () |
get z coordinate | |
const double & | operator[] (const size_t &k) const |
Access to the k_th entry (k in [0,2]). | |
double & | operator[] (const size_t &k) |
Access to the k_th entry (k in [0,2]). | |
const double & | operator() (const size_t &k) const |
Access to the k_th entry (k in [0,2]). | |
double & | operator() (const size_t &k) |
Access to the k_th entry (k in [0,2]). | |
void | set_zero () |
set every entry to 0 | |
double | dot (const v3 &p) const |
perform dot product between two v3 | |
double | norm () const |
get the norm of the vector | |
double | norm2 () const |
get the square norm of the vector | |
v3 | normalized () const |
normalize the vector to unit length | |
v3 | cross (const v3 &p) const |
compute cross product with an other vector | |
v3 & | operator+= (const v3 &p) |
internal + | |
v3 & | operator+= (const double &s) |
internal + | |
v3 & | operator-= (const v3 &p) |
internal - | |
v3 & | operator-= (const double &s) |
internal - | |
v3 & | operator*= (const double &s) |
internal * | |
v3 & | operator/= (const double &s) |
internal / | |
v3 | operator- () const |
unary negation | |
v3 | product_compontentwise (const v3 &p) const |
does componentwise mutliplication | |
v3 & | product_compontentwise_internal (const v3 &p) |
does componentwise mutliplication | |
std::string | to_string () const |
export the value as string cout<<v3(2,3,6) => 2 3 6 | |
Private Member Functions | |
void | assert_size (const size_t &k) const throw (std::exception) |
assert that a size_t belongs to [[0,2]] | |
Private Attributes | |
double | internal_x |
x coordinate | |
double | internal_y |
y coordinate | |
double | internal_z |
z coordinate | |
Friends | |
v3 | operator+ (const v3 &p1, const v3 &p2) |
+ operator | |
v3 | operator+ (const double &s, const v3 &p) |
+ operator | |
v3 | operator+ (const v3 &p, const double &s) |
+ operator | |
v3 | operator- (const v3 &p1, const v3 &p2) |
| |
v3 | operator- (const double &s, const v3 &p) |
| |
v3 | operator- (const v3 &p, const double &s) |
| |
v3 | operator* (const double &s, const v3 &p) |
multiply by a scalar operator | |
v3 | operator* (const v3 &p, const double &s) |
multiply by a scalar operator | |
v3 | operator/ (const v3 &p, const double &s) |
divide by a scalar operator | |
std::ostream & | operator<< (std::ostream &stream, const v3 &p) |
output the vector in ostream as (x,y,z) |
Vectors/Points 3D.
cpe::v3::v3 | ( | ) |
empty constructor
Referenced by cross(), normalized(), operator-(), and product_compontentwise().
cpe::v3::v3 | ( | const double & | x, | |
const double & | y, | |||
const double & | z | |||
) |
direct constructor
void cpe::v3::assert_size | ( | const size_t & | k | ) | const throw (std::exception) [private] |
assert that a size_t belongs to [[0,2]]
References cpe::string_converter::to_string().
Referenced by operator()(), and operator[]().
compute cross product with an other vector
References internal_x, internal_y, internal_z, v3(), x(), y(), and z().
Referenced by scene::fill_patch(), cpe::quaternion::operator*=(), and cpe::trackball::set_2d_coords().
double cpe::v3::dot | ( | const v3 & | p | ) | const |
perform dot product between two v3
References internal_x, internal_y, internal_z, x(), y(), and z().
Referenced by cpe::quaternion::operator*=(), and cpe::intersection_helper::sphere_ray().
double cpe::v3::norm | ( | ) | const |
get the norm of the vector
References norm2().
Referenced by normalized(), and cpe::trackball::set_2d_coords().
double cpe::v3::norm2 | ( | ) | const |
get the square norm of the vector
References internal_x, internal_y, and internal_z.
Referenced by norm(), and cpe::intersection_helper::sphere_ray().
v3 cpe::v3::normalized | ( | ) | const |
normalize the vector to unit length
Referenced by cpe::quaternion::axis(), cpe::mesh::normal_vertex(), cpe::quaternion::quaternion(), cpe::matrix4::rotation(), and cpe::matrix3::rotation().
double & cpe::v3::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 double & cpe::v3::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.
v3 & cpe::v3::operator*= | ( | const double & | s | ) |
internal *
References internal_x, internal_y, and internal_z.
v3 & cpe::v3::operator+= | ( | const double & | s | ) |
internal +
References internal_x, internal_y, and internal_z.
internal +
References internal_x, internal_y, internal_z, x(), y(), and z().
v3 cpe::v3::operator- | ( | ) | const |
unary negation
References internal_x, internal_y, internal_z, and v3().
v3 & cpe::v3::operator-= | ( | const double & | s | ) |
internal -
References internal_x, internal_y, and internal_z.
internal -
References internal_x, internal_y, internal_z, x(), y(), and z().
v3 & cpe::v3::operator/= | ( | const double & | s | ) |
internal /
References internal_x, internal_y, and internal_z.
double & cpe::v3::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 double & cpe::v3::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.
does componentwise mutliplication
References internal_x, internal_y, internal_z, v3(), x(), y(), and z().
does componentwise mutliplication
perform p=(p.x*p2.x,p.y*p2.y,p.z*p2.z)
References internal_x, internal_y, internal_z, x(), y(), and z().
void cpe::v3::set_zero | ( | ) |
set every entry to 0
References internal_x, internal_y, and internal_z.
std::string cpe::v3::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<<().
double & cpe::v3::x | ( | ) |
get x coordinate
References internal_x.
const double & cpe::v3::x | ( | ) | const |
get x coordinate
References internal_x.
Referenced by cpe::grid::build_meshgrid(), cross(), dot(), cpe::opengl_drawer::draw(), cpe::opengl_drawer::draw_curve(), cpe::opengl_drawer::draw_edges(), cpe::opengl_drawer::draw_normals(), cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), scene::draw_scene(), cpe::operator*(), cpe::operator+(), operator+=(), cpe::operator-(), operator-=(), cpe::operator/(), product_compontentwise(), product_compontentwise_internal(), and cpe::grid::write().
double & cpe::v3::y | ( | ) |
get y coordinate
References internal_y.
const double & cpe::v3::y | ( | ) | const |
get y coordinate
References internal_y.
Referenced by cpe::grid::build_meshgrid(), cross(), dot(), cpe::opengl_drawer::draw_curve(), cpe::opengl_drawer::draw_normals(), scene::draw_scene(), cpe::operator*(), cpe::operator+(), operator+=(), cpe::operator-(), operator-=(), cpe::operator/(), product_compontentwise(), product_compontentwise_internal(), and cpe::grid::write().
double & cpe::v3::z | ( | ) |
get z coordinate
References internal_z.
const double & cpe::v3::z | ( | ) | const |
get z coordinate
References internal_z.
Referenced by cross(), dot(), cpe::opengl_drawer::draw_curve(), cpe::opengl_drawer::draw_normals(), scene::draw_scene(), cpe::operator*(), cpe::operator+(), operator+=(), cpe::operator-(), operator-=(), cpe::operator/(), product_compontentwise(), product_compontentwise_internal(), and cpe::grid::write().
std::ostream& operator<< | ( | std::ostream & | stream, | |
const v3 & | p | |||
) | [friend] |
output the vector in ostream as (x,y,z)
double cpe::v3::internal_x [private] |
x coordinate
Referenced by cross(), dot(), norm2(), operator()(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), set_zero(), to_string(), and x().
double cpe::v3::internal_y [private] |
y coordinate
Referenced by cross(), dot(), norm2(), operator()(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), set_zero(), to_string(), and y().
double cpe::v3::internal_z [private] |
z coordinate
Referenced by cross(), dot(), norm2(), operator()(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), product_compontentwise(), product_compontentwise_internal(), set_zero(), to_string(), and z().