Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong result from TriDist #4

Open
hfogg01 opened this issue Mar 1, 2023 · 0 comments
Open

Wrong result from TriDist #4

hfogg01 opened this issue Mar 1, 2023 · 0 comments

Comments

@hfogg01
Copy link

hfogg01 commented Mar 1, 2023

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;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant