sanyaade-g2g-repos / quimeraengine

Automatically exported from code.google.com/p/quimeraengine
0 stars 1 forks source link

Corregir método IsConvex de QQuadrilateral #231

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hay que rehacerlo, de manera que compruebe primero si tiene algún ángulo 
interno superior a 180º o si es un polígono "cruzado", devolviendo false si 
se da cualquiera de las dos circunstancias. Hay que corregir y completar 
además la documentación del método y ver dónde se utiliza, de manera que se 
corrijan también aquellos métodos donde aparezca, pues el comportamiento 
seguramente cambiará.

Original issue reported on code.google.com by Lince3D@gmail.com on 12 Jan 2012 at 8:41

GoogleCodeExporter commented 8 years ago

Original comment by Lince3D@gmail.com on 12 Jan 2012 at 8:41

GoogleCodeExporter commented 8 years ago
Tarea liberada.

Original comment by anderson...@gmail.com on 22 Jan 2012 at 3:21

GoogleCodeExporter commented 8 years ago

Original comment by Lince3D@gmail.com on 24 Jan 2012 at 8:58

GoogleCodeExporter commented 8 years ago

Original comment by jwl...@gmail.com on 26 Jan 2012 at 8:41

GoogleCodeExporter commented 8 years ago

Original comment by jwl...@gmail.com on 26 Jan 2012 at 8:57

GoogleCodeExporter commented 8 years ago
Resultado de la revisión:

-Hay comprobaciones de más. Si se quitaran no sería necesario añadir asserts 
que añaden warnings (buscar ">>>>" abajo):

-----{

        if (ls1.IntersectionPoint(ls2, vAux) == EQIntersections::E_One) // Check if AD and BC edges cross themselves
        {
            // It checks both triangles (ABvAux and CDvAux)
            return (( PointsInSameSideOfLine(vPoint, vAux, this->A, this->B) &&
                      PointsInSameSideOfLine(vPoint, this->A, this->B, vAux) &&
                      PointsInSameSideOfLine(vPoint, this->B, vAux, this->A) ) ||
                    ( PointsInSameSideOfLine(vPoint, this->C, vAux, this->D) &&
                      PointsInSameSideOfLine(vPoint, vAux, this->D, this->C) &&
                      PointsInSameSideOfLine(vPoint, this->D, this->C, vAux) ));
        }
        else // Check if AB and CD edges cross themselves
        {
            ls1 = QLineSegment2D(this->A, this->B);
            ls2 = QLineSegment2D(this->C, this->D);

        >>>>if (ls1.IntersectionPoint(ls2, vAux) == EQIntersections::E_One)
            {
                // It checks both triangles (ADvAux and BCvAux)
                return (( PointsInSameSideOfLine(vPoint, this->A, vAux, this->D) &&
                      PointsInSameSideOfLine(vPoint, vAux, this->D, this->A) &&
                      PointsInSameSideOfLine(vPoint, this->D, this->A, vAux) ) ||
                    ( PointsInSameSideOfLine(vPoint, this->B, this->C, vAux) &&
                      PointsInSameSideOfLine(vPoint, this->C, vAux, this->B) &&
                      PointsInSameSideOfLine(vPoint, vAux, this->B, this->C) ));
            }
            // Something is wrong! : Its crossed quadrilateral but there are no intersections between edges.
            else
                QE_ASSERT(false)
        }

-----}

Ese bloque if, con su else, no es necesario puesto que ya has comrpbado, 
perimero, que es crossed, y segundo, que no son dos de los lados los que 
cruzan, por tanto, por fuerza, son los otros 2 lados y no tienes que 
comprobarlo. Es decir, tal caso "extraño" no se dará nunca.

-Lo mismo ocurre aquí (de nuevo, buscar por >>>>):

-----{

>>>>else if (this->IsConcaveHere(this->D, this->A, this->C, this->B)) // Its 
concave in D vertex
    {
        // We check the two triangles around D vertex
        return (( PointsInSameSideOfLine(vPoint, this->B, this->D, this->A) &&
                  PointsInSameSideOfLine(vPoint, this->D, this->A, this->B) &&
                  PointsInSameSideOfLine(vPoint, this->A, this->B, this->D) ) ||
                ( PointsInSameSideOfLine(vPoint, this->C, this->D, this->B) &&
                  PointsInSameSideOfLine(vPoint, this->D, this->B, this->C) &&
                  PointsInSameSideOfLine(vPoint, this->B, this->C, this->D) ));
    }
    else // Something is wrong! : its concave but no vertex has concavity
        QE_ASSERT(false)

------}

Aquí, éste es el último caso de la comprobación de los 4 vértices. Si los 
3 primeros no son, por fuerza será el 4º.

Original comment by Lince3D@gmail.com on 28 Jan 2012 at 11:46

GoogleCodeExporter commented 8 years ago

Original comment by jwl...@gmail.com on 30 Jan 2012 at 10:28

GoogleCodeExporter commented 8 years ago
Resultado de la revisión: Correcta.

Original comment by Lince3D@gmail.com on 30 Jan 2012 at 5:29