gk::Triangle Struct Reference

representation d'un triangle 'geometrique'. More...

#include <Triangle.h>

Inheritance diagram for gk::Triangle:
gk::PNTriangle gk::PTNTriangle

List of all members.

Public Member Functions

 Triangle ()
 constructeur par defaut.
 Triangle (const Point &a, const Point &b, const Point &c)
 construit un triangle connaissant ses 3 sommets.
 ~Triangle ()
 destructeur.
float getArea () const
Normal getNormal () const
Vector local (const Vector &v) const
 changement de repere, renvoie le vecteur dans le repere local (bitangent, tangent, normal)
Vector world (const Vector &v) const
 changement de repere, renvoie le vecteur dans le repere global.
BBox getBBox () const
Triangle transform (const Transform &t)
 renvoie un triangle transforme par 't'.
bool Intersect (const Ray &ray, const float htmax, float &rt, float &ru, float &rv) const
 intersection avec un rayon.
Point getUVPoint (const float u, const float v) const
 renvoie un point a l'interieur du triangle connaissant ses coordonnees barycentriques.
float sampleUniform (Sampler &sampler, Point &p) const
 choisit un point aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisi.
float pdfUniform (const Point &p) const
 renvoie la probabilite de choisir le point p aleatoirement.

Public Attributes

Point a
Point b
Point c
float area

Detailed Description

representation d'un triangle 'geometrique'.


Member Function Documentation

bool gk::Triangle::Intersect ( const Ray ray,
const float  htmax,
float &  rt,
float &  ru,
float &  rv 
) const [inline]

intersection avec un rayon.

renvoie faux s'il n'y a pas d'intersection valide, une intersection peut exister mais peut ne pas se trouver dans l'intervalle [0 htmax] du rayon.
renvoie vrai + les coordonnees barycentriques (ru, rv) du point d'intersection + sa position le long du rayon (rt).
convention barycentrique : t(u, v)= (1 - u - v) * a + u * b + v * c
utiliser Mesh::getUVNormal() et Mesh::getUVTexCoord() pour interpoler les attributs du point d'intersection.
ou PNTriangle::getUVNormal().

le parametre htmax permet de trouver tres facilement l'intersection la plus proche de l'origine du rayon.

        float t= ray.tmax;      // ou t= HUGE_VAL; la plus grande distance le long du rayon.
        // rechercher le triangle le plus proche de l'origine du rayon
        for(int i= 0; i < n; i++)
        {
            float rt;
            float ru, rv;
            if(triangle[i].Intersect(ray, t, rt, ru, rv))
                t= rt;
        }

References gk::Cross(), gk::Ray::d, gk::Dot(), and gk::Ray::o.

Point gk::Triangle::getUVPoint ( const float  u,
const float  v 
) const [inline]

renvoie un point a l'interieur du triangle connaissant ses coordonnees barycentriques.

convention p(u, v)= (1 - u - v) * a + u * b + v * c

float gk::Triangle::pdfUniform ( const Point p  )  const [inline]

renvoie la probabilite de choisir le point p aleatoirement.

remarque: le point doit appartenir au triangle.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Friends
Generated on Mon Jan 9 15:57:18 2012 for gKitGL by  doxygen 1.6.3