Skip to content

Wrong result from TriDist #4

@hfogg01

Description

@hfogg01

I have encountered a bug where TriDist returns the wrong result.

The sample code below outlines the issue:

#include <stdio.h>
#include <math.h>
#include "PQP.h"

int main()
{
PQP_Model *b1 = new PQP_Model;
PQP_Model *b2 = new PQP_Model;

PQP_REAL triangleS[3][3] = {
                 {8000.0000000000036,
                  6817.7672478170962,
                  571.00166381103077},
                 {7500.0000000000009,
                  6817.7672478170962,
                  571.00166381103077},
                 {7500.0000000000009,
                  6327.6345143037688,
                  571.00166381103077} };

PQP_REAL triangleT[3][3] = {
           {8000.0000000000009,
            6327.6345143037670,
            88.336618780016408},
           {7500.0,
            6327.6345143037670,
            88.336618780016408},
           {7500.0,
            6327.6345143037670,
            1015.9309593449836} };

b1->BeginModel();
b2->BeginModel();

b1->AddTri(triangleS[0], triangleS[1], triangleS[2], 0);
b2->AddTri(triangleT[0], triangleT[1], triangleT[2], 0);

b1->EndModel();
b2->EndModel();

PQP_REAL R1[3][3], R2[3][3], T1[3], T2[3];

R1[0][0] = R1[1][1] = R1[2][2] = 1.0;
R1[0][1] = R1[1][0] = R1[2][0] = 0.0;
R1[0][2] = R1[1][2] = R1[2][1] = 0.0;

R2[0][0] = R2[1][1] = R2[2][2] = 1.0;
R2[0][1] = R2[1][0] = R2[2][0] = 0.0;
R2[0][2] = R2[1][2] = R2[2][1] = 0.0;

T1[0] = 0.0;  T1[1] = 0.0; T1[2] = 0.0;
T2[0] = 0.0;  T2[1] = 0.0; T2[2] = 0.0;

PQP_DistanceResult dres;
PQP_Distance(&dres, R1, T1, b1, R2, T2, b2, 0.0, 0.0);

//dres.distance = 687.89217334989303
//but it should be:
//dres.distance = 1.8189894035458565e-12

delete b1;
delete b2;

return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions