cpe::v3 Class Reference

Vectors/Points 3D. More...

List of all members.

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
v3operator+= (const v3 &p)
 internal +
v3operator+= (const double &s)
 internal +
v3operator-= (const v3 &p)
 internal -
v3operator-= (const double &s)
 internal -
v3operator*= (const double &s)
 internal *
v3operator/= (const double &s)
 internal /
v3 operator- () const
 unary negation
v3 product_compontentwise (const v3 &p) const
 does componentwise mutliplication
v3product_compontentwise_internal (const v3 &p)
 does componentwise mutliplication
void scale (const double &sx, const double &sy, const double &sz)
 internal scaling (similar to componentwise)
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
 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)
 
  • operator

v3 operator- (const double &s, const v3 &p)
 
  • operator

v3 operator- (const v3 &p, const double &s)
 
  • operator

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)

Detailed Description

Vectors/Points 3D.


Constructor & Destructor Documentation

empty constructor

Referenced by cross(), normalized(), operator-(), and product_compontentwise().

cpe::v3::v3 ( const double &  x,
const double &  y,
const double &  z 
)

direct constructor


Member Function Documentation

void cpe::v3::assert_size ( const size_t &  k) const [private]

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

Referenced by operator()(), and operator[]().

v3 cpe::v3::cross ( const v3 p) const

compute cross product with an other vector

References internal_x, internal_y, internal_z, v3(), x(), y(), and z().

Referenced by cpe::camera::get_screen_coordinate().

+ Here is the call graph for this function:

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::plane::intersect(), cpe::sphere::intersect(), and cpe::ray::reflected_ray().

+ Here is the call graph for this function:

double cpe::v3::norm ( ) const

get the norm of the vector

References norm2().

Referenced by normalized().

+ Here is the call graph for this function:

double cpe::v3::norm2 ( ) const

get the square norm of the vector

References internal_x, internal_y, and internal_z.

Referenced by norm().

normalize the vector to unit length

References norm(), and v3().

Referenced by cpe::camera::get_screen_coordinate(), and cpe::ray::reflected_ray().

+ Here is the call graph for this function:

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.

+ Here is the call graph for this function:

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.

+ Here is the call graph for this function:

v3 & cpe::v3::operator*= ( const double &  s)

internal *

References internal_x, internal_y, and internal_z.

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

internal +

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

+ Here is the call graph for this function:

v3 & cpe::v3::operator+= ( const double &  s)

internal +

References internal_x, internal_y, and internal_z.

v3 cpe::v3::operator- ( ) const

unary negation

References internal_x, internal_y, internal_z, and v3().

+ Here is the call graph for this function:

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

internal -

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

+ Here is the call graph for this function:

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.

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.

+ Here is the call graph for this function:

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.

+ Here is the call graph for this function:

v3 cpe::v3::product_compontentwise ( const v3 p) const

does componentwise mutliplication

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

References internal_x, internal_y, internal_z, v3(), x(), y(), and z().

+ Here is the call graph for this function:

does componentwise mutliplication

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

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

+ Here is the call graph for this function:

void cpe::v3::scale ( const double &  sx,
const double &  sy,
const double &  sz 
)

internal scaling (similar to componentwise)

References internal_x, internal_y, and internal_z.

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.

double & cpe::v3::y ( )

get y coordinate

References internal_y.

double & cpe::v3::z ( )

get z coordinate

References internal_z.


Friends And Related Function Documentation

v3 operator* ( const double &  s,
const v3 p 
) [friend]

multiply by a scalar operator

v3 operator* ( const v3 p,
const double &  s 
) [friend]

multiply by a scalar operator

v3 operator+ ( const v3 p1,
const v3 p2 
) [friend]

  • operator

v3 operator+ ( const double &  s,
const v3 p 
) [friend]

  • operator

v3 operator+ ( const v3 p,
const double &  s 
) [friend]

  • operator

v3 operator- ( const v3 p1,
const v3 p2 
) [friend]

  • operator

v3 operator- ( const double &  s,
const v3 p 
) [friend]

  • operator

v3 operator- ( const v3 p,
const double &  s 
) [friend]

  • operator

v3 operator/ ( const v3 p,
const double &  s 
) [friend]

divide by a scalar operator

std::ostream& operator<< ( std::ostream &  stream,
const v3 p 
) [friend]

output the vector in ostream as (x,y,z)


Member Data Documentation


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