cpe Namespace Reference

Namespace for CPE classes. More...

Classes

class  matrix2
 Matrix 2x2. More...
 
class  exception_matrix2
 Special exception class for v3. More...
 
class  matrix3
 Matrix 3x3. More...
 
class  exception_matrix3
 Special exception class for v3. More...
 
class  matrix4
 Matrix 4x4. More...
 
class  exception_matrix4
 Special exception class for v3. More...
 
class  quaternion
 Quaternion class. More...
 
class  exception_quaternion
 Special exception class for v4. More...
 
class  vec2
 Vectors/Points 2D. More...
 
class  exception_vec2
 Special exception class for v2. More...
 
class  vec3
 Vectors/Points 3D. More...
 
class  exception_vec3
 Special exception class for v3. More...
 
class  vec4
 Vectors/Points 4D. More...
 
class  exception_vec4
 Special exception class for v4. More...
 
class  exception_cpe
 General exception class. More...
 
class  color
 Container class for (r,g,b) color. Each component is between [0,1]. More...
 
class  exception_color
 Exception class for color. More...
 
class  image
 Container for picture data. Data are stored as unsigned char [0,255]. More...
 
class  exception_image
 Special exception class for image. More...
 
class  image_zbuffer
 Container for picture data. Data are stored as unsigned char [0,255]. More...
 
struct  line_discrete
 Container for vector of 2D integer coordinates. More...
 
class  pos2
 Container for 2D integer positions (pixel position) More...
 
class  exception_p2d
 Exception class for p2d. More...
 
struct  line_pointer
 
struct  triangle_scanline
 
class  z_buffer
 Class to manage a depth-buffer. More...
 
class  mesh
 Container class for a generic mesh with normal, color, texture, ... More...
 
class  exception_mesh
 Special exception class for image. More...
 
class  mesh_io
 Helper class for I/O mesh. More...
 
class  render_engine
 Renderer. More...
 
struct  scene
 A 3D scene containing a projection matrix and a light. More...
 
struct  shading
 Container for shading parameters (ambiant,diffuse,specular) More...
 
struct  vertex
 A vertex structure containing a position, normal, and a color. More...
 

Typedefs

typedef float color_component
 

Functions

matrix2 operator+ (const double &s, const matrix2 &m)
 
  • operator
More...
 
matrix2 operator- (const double &s, const matrix2 &m)
 
  • operator
More...
 
matrix2 operator* (const double &s, const matrix2 &m)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const matrix2 &m)
 output the vector in ostream More...
 
matrix3 operator+ (const double &s, const matrix3 &m)
 
  • operator
More...
 
matrix3 operator- (const double &s, const matrix3 &m)
 
  • operator
More...
 
matrix3 operator* (const double &s, const matrix3 &m)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const matrix3 &m)
 output the vector in ostream More...
 
matrix4 operator+ (const double &s, const matrix4 &m)
 
  • operator
More...
 
matrix4 operator- (const double &s, const matrix4 &m)
 
  • operator
More...
 
matrix4 operator* (const double &s, const matrix4 &m)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const matrix4 &m)
 output the vector in ostream More...
 
quaternion operator* (const double &s, const quaternion &q)
 multiplication with scalar More...
 
vec2 operator+ (const double &s, const vec2 &p)
 
  • operator
More...
 
vec2 operator- (const double &s, const vec2 &p)
 
  • operator
More...
 
vec2 operator* (const double &s, const vec2 &p)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const vec2 &p)
 output the vector in ostream as (x,y,z) More...
 
vec3 operator+ (const double &s, const vec3 &p)
 
  • operator
More...
 
vec3 operator- (const double &s, const vec3 &p)
 
  • operator
More...
 
vec3 operator* (const double &s, const vec3 &p)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const vec3 &p)
 output the vector in ostream as (x,y,z) More...
 
vec4 operator+ (const double &s, const vec4 &p)
 
  • operator
More...
 
vec4 operator- (const double &s, const vec4 &p)
 
  • operator
More...
 
vec4 operator* (const double &s, const vec4 &p)
 multiply by a scalar operator More...
 
std::ostream & operator<< (std::ostream &stream, const vec4 &p)
 output the vector in ostream as (x,y,z) More...
 
std::ostream & operator<< (std::ostream &stream, const color &c)
 standard output More...
 
coloroperator+= (color &c0, const color &c1)
 
coloroperator-= (color &c0, const color &c1)
 
color operator+ (const color &c0, const color &c1)
 
color operator- (const color &c0, const color &c1)
 
coloroperator*= (color &c0, float alpha)
 
coloroperator/= (color &c0, float alpha)
 
color operator* (const color &c0, float alpha)
 
color operator* (float alpha, const color &c0)
 
color operator/ (const color &c0, float alpha)
 
void draw_line (image &im, const pos2 &u0, const pos2 &u1, const color &c=color(1, 0, 0))
 draw line on image with uniform color More...
 
void draw_triangle (image &im, const pos2 &u0, const pos2 &u1, const pos2 &u2, const color &c=color(1, 0, 0))
 draw triangle with uniform color More...
 
void export_ppm (const std::string &filename, const image &pic)
 Export the picture into ppm format (ascii) More...
 
void export_ppm (const std::string &filename, const z_buffer &buffer)
 Export the z-buffer as a gray picture into ppm format (ascii) More...
 
image read_ppm (const std::string &filename)
 read a ppm picture format More...
 
line_discrete swap_xy (const line_discrete &line)
 Return a new line_discrete with swaped values between x & y. More...
 
line_discrete symetry_x (const line_discrete &line)
 Return a new line_discrete which is symetric with respect to x-coordinate. More...
 
line_discrete symetry_y (const line_discrete &line)
 Return a new line_discrete which is symetric with respect to y-coordinate. More...
 
line_discrete reverse (const line_discrete &line)
 Return a new line_discrete in the reverse order (last entry <-> first entry) More...
 
line_discrete compute_line (const pos2 &u0, const pos2 &u1)
 Compute a line_discrete between any positions (u0,u1) More...
 
line_discrete compute_line_vertical (int x, int y_min, int y_max)
 Compute a horizontal line at constant x between (y_min,y_max). More...
 
line_discrete compute_line_horizontal (int x_min, int x_max, int y)
 Compute a horizontal line at constant y between (x_min,x_max). More...
 
line_discrete compute_line_diagonal (int x0, int y0, int x1, int y1)
 Compute diagonal line. More...
 
line_discrete compute_bresenham (int x0, int y0, int x1, int y1)
 Compute bresenham algorithm in the first quadrant. More...
 
std::ostream & operator<< (std::ostream &stream, const pos2 &u)
 standard output More...
 
pos2operator+= (pos2 &u1, const pos2 &u2)
 internal sum between two positions More...
 
pos2operator-= (pos2 &u1, const pos2 &u2)
 internal diff between two positions More...
 
pos2 operator+ (const pos2 &u1, const pos2 &u2)
 sum between two positions More...
 
pos2 operator- (const pos2 &u1, const pos2 &u2)
 diff between two positions More...
 
mesh operator+ (const vec3 &x, const mesh &m)
 
mesh operator+ (const mesh &m, const vec3 &x)
 
mesh operator- (const mesh &m, const vec3 &x)
 
mesh operator* (const float &s, const mesh &m)
 
mesh operator* (const mesh &m, const float &s)
 
pos2 real_coordinate_to_image_coordinate (const vec3 &p, int Nx, int Ny)
 Convert real coordinate to image coordinate. More...
 
color apply_shading (const vertex &v, const scene &scene3d, const shading &shad)
 Apply gouraud shading on the given vertex. More...
 
color apply_shading (const vec3 &p, const vec3 &n, const color &c, const scene &scene3d, const shading &shad)
 Apply gouraud shading. More...
 

Detailed Description

Namespace for CPE classes.

Typedef Documentation

typedef float cpe::color_component

Function Documentation

color cpe::apply_shading ( const vertex &  v,
const scene &  scene3d,
const shading &  shad 
)

Apply gouraud shading on the given vertex.

References cpe::vertex::c, cpe::vertex::n, and cpe::vertex::p.

color cpe::apply_shading ( const vec3 &  p,
const vec3 &  n,
const color &  c,
const scene &  scene3d,
const shading &  shad 
)

Apply gouraud shading.

line_discrete cpe::compute_bresenham ( int  x0,
int  y0,
int  x1,
int  y1 
)

Compute bresenham algorithm in the first quadrant.

Precondition
x0<x1 && y0<y1 && (x1-x0)>(y1-y0)
line_discrete cpe::compute_line ( const pos2 &  u0,
const pos2 &  u1 
)

Compute a line_discrete between any positions (u0,u1)

References cpe::line_discrete::add(), compute_line_vertical(), reverse(), cpe::pos2::x(), and cpe::pos2::y().

Referenced by cpe::triangle_scanline::triangle_scanline().

+ Here is the call graph for this function:

line_discrete cpe::compute_line_diagonal ( int  x0,
int  y0,
int  x1,
int  y1 
)

Compute diagonal line.

Precondition
x0<x1 && y0<y1 && x1-x0==y1-y0
line_discrete cpe::compute_line_horizontal ( int  x_min,
int  x_max,
int  y 
)

Compute a horizontal line at constant y between (x_min,x_max).

Precondition
x_min<x_max
line_discrete cpe::compute_line_vertical ( int  x,
int  y_min,
int  y_max 
)

Compute a horizontal line at constant x between (y_min,y_max).

Precondition
y_min<y_max

References cpe::line_discrete::add().

Referenced by compute_line().

+ Here is the call graph for this function:

void cpe::draw_line ( image &  im,
const pos2 &  u0,
const pos2 &  u1,
const color &  c 
)

draw line on image with uniform color

References cpe::image::check_position().

+ Here is the call graph for this function:

void cpe::draw_triangle ( image &  im,
const pos2 &  u0,
const pos2 &  u1,
const pos2 &  u2,
const color &  c 
)

draw triangle with uniform color

References cpe::triangle_scanline::first_point, cpe::triangle_scanline::last_point, and cpe::triangle_scanline::size().

+ Here is the call graph for this function:

void cpe::export_ppm ( const std::string &  filename,
const image &  pic 
)

Export the picture into ppm format (ascii)

Parameters
std::stringfilename: file to store the picture
imagepic: image to store

References cpe::color::b(), cpe::color::clamp(), cpe::color::g(), MACRO_EXCEPTION_PARAMETER, cpe::image::Nx(), cpe::image::Ny(), and cpe::color::r().

Referenced by cpe::z_buffer::export_file(), cpe::image::export_file(), and cpe::image_zbuffer::export_z_buffer().

+ Here is the call graph for this function:

void cpe::export_ppm ( const std::string &  filename,
const z_buffer &  buffer 
)

Export the z-buffer as a gray picture into ppm format (ascii)

Parameters
std::stringfilename: file to store the picture
z_bufferbuffer: depth-map to store

References cpe::color::b(), cpe::color::clamp(), cpe::color::g(), cpe::z_buffer::get_max(), cpe::z_buffer::get_min(), cpe::color::r(), cpe::z_buffer::size_x(), and cpe::z_buffer::size_y().

+ Here is the call graph for this function:

mesh cpe::operator* ( const float &  s,
const mesh &  m 
)
mesh cpe::operator* ( const mesh &  m,
const float &  s 
)
matrix2 cpe::operator* ( const double &  s,
const matrix2 &  m 
)

multiply by a scalar operator

matrix3 cpe::operator* ( const double &  s,
const matrix3 &  m 
)

multiply by a scalar operator

color cpe::operator* ( const color &  c0,
float  alpha 
)
color cpe::operator* ( float  alpha,
const color &  c0 
)
vec2 cpe::operator* ( const double &  s,
const vec2 &  p 
)

multiply by a scalar operator

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

+ Here is the call graph for this function:

vec3 cpe::operator* ( const double &  s,
const vec3 &  p 
)

multiply by a scalar operator

References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

vec4 cpe::operator* ( const double &  s,
const vec4 &  p 
)

multiply by a scalar operator

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

matrix4 cpe::operator* ( const double &  s,
const matrix4 &  m 
)

multiply by a scalar operator

References cpe::matrix4::pointer().

+ Here is the call graph for this function:

quaternion cpe::operator* ( const double &  s,
const quaternion &  q 
)

multiplication with scalar

color & cpe::operator*= ( color &  c0,
float  alpha 
)

References cpe::color::b(), cpe::color::g(), and cpe::color::r().

+ Here is the call graph for this function:

pos2 cpe::operator+ ( const pos2 &  u1,
const pos2 &  u2 
)

sum between two positions

mesh cpe::operator+ ( const vec3 &  x,
const mesh &  m 
)
mesh cpe::operator+ ( const mesh &  m,
const vec3 &  x 
)
matrix2 cpe::operator+ ( const double &  s,
const matrix2 &  m 
)

  • operator

matrix3 cpe::operator+ ( const double &  s,
const matrix3 &  m 
)

  • operator

color cpe::operator+ ( const color &  c0,
const color &  c1 
)
vec2 cpe::operator+ ( const double &  s,
const vec2 &  p 
)

  • operator

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

+ Here is the call graph for this function:

vec3 cpe::operator+ ( const double &  s,
const vec3 &  p 
)

  • operator

References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

matrix4 cpe::operator+ ( const double &  s,
const matrix4 &  m 
)

  • operator

References cpe::matrix4::pointer().

+ Here is the call graph for this function:

vec4 cpe::operator+ ( const double &  s,
const vec4 &  p 
)

  • operator

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

pos2 & cpe::operator+= ( pos2 &  u1,
const pos2 &  u2 
)

internal sum between two positions

References cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function:

color & cpe::operator+= ( color &  c0,
const color &  c1 
)

References cpe::color::b(), cpe::color::g(), and cpe::color::r().

+ Here is the call graph for this function:

pos2 cpe::operator- ( const pos2 &  u1,
const pos2 &  u2 
)

diff between two positions

mesh cpe::operator- ( const mesh &  m,
const vec3 &  x 
)
color cpe::operator- ( const color &  c0,
const color &  c1 
)
matrix2 cpe::operator- ( const double &  s,
const matrix2 &  m 
)

  • operator

References cpe::matrix2::pointer().

+ Here is the call graph for this function:

matrix3 cpe::operator- ( const double &  s,
const matrix3 &  m 
)

  • operator

References cpe::matrix3::pointer().

+ Here is the call graph for this function:

vec2 cpe::operator- ( const double &  s,
const vec2 &  p 
)

  • operator

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

+ Here is the call graph for this function:

vec3 cpe::operator- ( const double &  s,
const vec3 &  p 
)

  • operator

References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

matrix4 cpe::operator- ( const double &  s,
const matrix4 &  m 
)

  • operator

References cpe::matrix4::pointer().

+ Here is the call graph for this function:

vec4 cpe::operator- ( const double &  s,
const vec4 &  p 
)

  • operator

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

pos2 & cpe::operator-= ( pos2 &  u1,
const pos2 &  u2 
)

internal diff between two positions

References cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function:

color & cpe::operator-= ( color &  c0,
const color &  c1 
)

References cpe::color::b(), cpe::color::g(), and cpe::color::r().

+ Here is the call graph for this function:

color cpe::operator/ ( const color &  c0,
float  alpha 
)
color & cpe::operator/= ( color &  c0,
float  alpha 
)

References cpe::color::b(), cpe::color::g(), MACRO_EXCEPTION_PARAMETER, and cpe::color::r().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const pos2 &  u 
)

standard output

References cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const color &  c 
)

standard output

References cpe::color::b(), cpe::color::g(), and cpe::color::r().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const vec2 &  p 
)

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

References cpe::vec2::to_string().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const matrix2 &  _m 
)

output the vector in ostream

References cpe::matrix2::pointer().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const matrix3 &  _m 
)

output the vector in ostream

References cpe::matrix3::pointer().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const vec3 &  p 
)

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

References cpe::vec3::to_string().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const vec4 &  p 
)

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

References cpe::vec4::to_string().

+ Here is the call graph for this function:

std::ostream & cpe::operator<< ( std::ostream &  stream,
const matrix4 &  _m 
)

output the vector in ostream

References cpe::matrix4::pointer().

+ Here is the call graph for this function:

image cpe::read_ppm ( const std::string &  filename)

read a ppm picture format

Parameters
std::stringfilename: path of the file to read

References MACRO_EXCEPTION_PARAMETER.

Referenced by cpe::image::image().

pos2 cpe::real_coordinate_to_image_coordinate ( const vec3 &  p,
int  Nx,
int  Ny 
)

Convert real coordinate to image coordinate.

References cpe::vec3::x(), and cpe::vec3::y().

+ Here is the call graph for this function:

line_discrete cpe::reverse ( const line_discrete &  line)

Return a new line_discrete in the reverse order (last entry <-> first entry)

References cpe::line_discrete::add(), cpe::line_discrete::coordinate, and cpe::line_discrete::size().

Referenced by compute_line().

+ Here is the call graph for this function:

line_discrete cpe::swap_xy ( const line_discrete &  line)

Return a new line_discrete with swaped values between x & y.

References cpe::line_discrete::add(), cpe::line_discrete::coordinate, cpe::line_discrete::size(), cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function:

line_discrete cpe::symetry_x ( const line_discrete &  line)

Return a new line_discrete which is symetric with respect to x-coordinate.

References cpe::line_discrete::coordinate, cpe::line_discrete::size(), cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function:

line_discrete cpe::symetry_y ( const line_discrete &  line)

Return a new line_discrete which is symetric with respect to y-coordinate.

References cpe::line_discrete::coordinate, cpe::line_discrete::size(), cpe::pos2::x(), and cpe::pos2::y().

+ Here is the call graph for this function: