Technopedia Center
PMB University Brochure
Faculty of Engineering and Computer Science
S1 Informatics S1 Information Systems S1 Information Technology S1 Computer Engineering S1 Electrical Engineering S1 Civil Engineering

faculty of Economics and Business
S1 Management S1 Accountancy

Faculty of Letters and Educational Sciences
S1 English literature S1 English language education S1 Mathematics education S1 Sports Education
  • Registerasi
  • Brosur UTI
  • Kip Scholarship Information
  • Performance
  1. Weltenzyklopädie
  2. Algorithme d'intersection de Möller-Trumbore — Wikipédia
Algorithme d'intersection de Möller-Trumbore — Wikipédia 👆 Click Here! Read More..
Un article de Wikipédia, l'encyclopédie libre.

L'algorithme d'intersection "rayon-triangle" de Möller-Trumbore, nommé après de ses inventeurs Tomas Möller et Ben Trumbore, est une méthode de calcul rapide de l'intersection d'un rayon et d'un triangle en trois dimensions, sans nécessiter le pré-calcul de l'équation du plan contenant le triangle[1]. Il est utilisé en infographie pour effectuer du lancer de rayons sur un maillage triangulaire[2].

Implémentation C++

[modifier | modifier le code]

Voici une implémentation de l'algorithme en C++ :

bool RayIntersectsTriangle(Vector3D rayOrigin, 
                           Vector3D rayVector, 
                           Triangle* inTriangle,
                           Vector3D& outIntersectionPoint)
{
    const float EPSILON = 0.0000001;
    Vector3D vertex0 = inTriangle->vertex0;
    Vector3D vertex1 = inTriangle->vertex1;  
    Vector3D vertex2 = inTriangle->vertex2;
    Vector3D edge1, edge2, h, s, q;
    float a,f,u,v;
    edge1 = vertex1 - vertex0;
    edge2 = vertex2 - vertex0;
    h = rayVector.crossProduct(edge2);
    a = edge1.dotProduct(h);
    if (a > -EPSILON && a < EPSILON)
        return false;    // Le rayon est parallèle au triangle.

    f = 1.0/a;
    s = rayOrigin - vertex0;
    u = f * (s.dotProduct(h));
    if (u < 0.0 || u > 1.0)
        return false;
    q = s.crossProduct(edge1);
    v = f * rayVector.dotProduct(q);
    if (v < 0.0 || u + v > 1.0)
        return false;

    // On calcule t pour savoir ou le point d'intersection se situe sur la ligne.
    float t = f * edge2.dotProduct(q);
    if (t > EPSILON) // Intersection avec le rayon
    {
        outIntersectionPoint = rayOrigin + rayVector * t;
        return true;
    }
    else // On a bien une intersection de droite, mais pas de rayon.
        return false;
}

Implémentation Java

[modifier | modifier le code]

Ce qui suit est une implémentation de l'algorithme en Java, utilisant javax.vecmath (API Java 3D):

public class MollerTrumbore {

    private static double EPSILON = 0.0000001;

    public static boolean rayIntersectsTriangle(Point3d rayOrigin, 
                                                Vector3d rayVector,
                                                Triangle inTriangle,
                                                Point3d outIntersectionPoint) {
        Point3d vertex0 = inTriangle.getVertex0();
        Point3d vertex1 = inTriangle.getVertex1();
        Point3d vertex2 = inTriangle.getVertex2();
        Vector3d edge1 = new Vector3d();
        Vector3d edge2 = new Vector3d();
        Vector3d h = new Vector3d();
        Vector3d s = new Vector3d();
        Vector3d q = new Vector3d();
        double a, f, u, v;
        edge1.sub(vertex1, vertex0);
        edge2.sub(vertex2, vertex0);
        h.cross(rayVector, edge2);
        a = edge1.dot(h);
        if (a > -EPSILON && a < EPSILON) {
            return false;    // Le rayon est parallèle au triangle.
        }
        f = 1.0 / a;
        s.sub(rayOrigin, vertex0);
        u = f * (s.dot(h));
        if (u < 0.0 || u > 1.0) {
            return false;
        }
        q.cross(s, edge1);
        v = f * rayVector.dot(q);
        if (v < 0.0 || u + v > 1.0) {
            return false;
        }
        // On calcule t pour savoir ou le point d'intersection se situe sur la ligne.
        double t = f * edge2.dot(q);
        if (t > EPSILON) // // Intersection avec le rayon
        {
            outIntersectionPoint.set(0.0, 0.0, 0.0);
            outIntersectionPoint.scaleAdd(t, rayVector, rayOrigin);
            return true;
        } else // On a bien une intersection de droite, mais pas de rayon.
        {
            return false;
        }
    }
}

Voir aussi

[modifier | modifier le code]

Articles connexes

[modifier | modifier le code]
  • Ray tracing
  • Algorithme d'intersection de Badouel
  • Algorithme de Schlick–Subrenat[3] pour l'intersection rayon-quadrilatère

Liens externes

[modifier | modifier le code]
  • Version MATLAB de cet algorithme (hautement vectorisé)
  • Algorithme d'intersection rayon-triangle de Baldwin-Weber

Notes et références

[modifier | modifier le code]

(en) Cet article est partiellement ou en totalité issu de la page de Wikipédia en anglais intitulée « Möller–Trumbore intersection algorithm » (voir la liste des auteurs).

  1. ↑ (en) Tomas Möller et Trumbore, « Fast, Minimum Storage Ray-Triangle Intersection », Journal of Graphics Tools, vol. 2,‎ 1997, p. 21–28 (DOI 10.1080/10867651.1997.10487468)
  2. ↑ (en) « Ray-Triangle Intersection », lighthouse3d (consulté le 10 septembre 2017)
  3. ↑ Intersection de rayons de surfaces tessellées: quadrangles contre triangles, Schlick C., Subrenat G. Graphics Gems 1993
  • icône décorative Portail de l’imagerie numérique
Ce document provient de « https://fr.teknopedia.teknokrat.ac.id/w/index.php?title=Algorithme_d%27intersection_de_Möller-Trumbore&oldid=208216593 ».
Catégories :
  • 3D
  • Algorithme d'infographie
Catégories cachées :
  • Portail:Imagerie numérique/Articles liés
  • Portail:Informatique/Articles liés
  • Portail:Technologies/Articles liés
  • Pages avec des traductions non relues

  • indonesia
  • Polski
  • الرية
  • Deutsch
  • English
  • Español
  • Français
  • Italiano
  • مصر
  • Nederlands
  • 本語
  • Português
  • Sinugboanong Binisaya
  • Svenska
  • Українска
  • Tiếng Việt
  • Winaray
  • 中文
  • Русски
Sunting pranala
Pusat Layanan

UNIVERSITAS TEKNOKRAT INDONESIA | ASEAN's Best Private University
Jl. ZA. Pagar Alam No.9 -11, Labuhan Ratu, Kec. Kedaton, Kota Bandar Lampung, Lampung 35132
Phone: (0721) 702022
Email: pmb@teknokrat.ac.id