Skip to content

Commit

Permalink
Merge pull request #36 from MattiaMontanari/moveHFFsInIFs
Browse files Browse the repository at this point in the history
Fix #29 and clean simplex struct
  • Loading branch information
MattiaMontanari authored Nov 23, 2022
2 parents 7a018a3 + 9c8a115 commit 866c01e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions include/openGJK/openGJK.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ typedef struct gkPolytope_ {
/// @brief Structure of the simplex
typedef struct gkSimplex_ {
int nvrtx; // Number of simplex's vertices
int wids[4]; // Label of the simplex's vertices
gkFloat lambdas[4]; // Barycentric coordiantes for each vertex
gkFloat vrtx[4][3]; // Coordinates of simplex's vertices
} gkSimplex;

Expand Down
5 changes: 3 additions & 2 deletions openGJK.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ inline static void S2D(gkSimplex *s, gkFloat *v) {
gkFloat *s3p = s->vrtx[0];
int hff1f_s12 = hff1(s1p, s2p);
int hff1f_s13 = hff1(s1p, s3p);
int hff2f_23 = !hff2(s1p, s2p, s3p);
int hff2f_32 = !hff2(s1p, s3p, s2p);

if (hff1f_s12) {
int hff2f_23 = !hff2(s1p, s2p, s3p);
if (hff2f_23) {
if (hff1f_s13) {
int hff2f_32 = !hff2(s1p, s3p, s2p);
if (hff2f_32) {
projectOnPlane(s1p, s2p, s3p, v); // Update s, no need to update c
return; // Return V{1,2,3}
Expand All @@ -250,6 +250,7 @@ inline static void S2D(gkSimplex *s, gkFloat *v) {
return; // Return V{1,2}
}
} else if (hff1f_s13) {
int hff2f_32 = !hff2(s1p, s3p, s2p);
if (hff2f_32) {
projectOnPlane(s1p, s2p, s3p, v); // Update s, no need to update v
return; // Return V{1,2,3}
Expand Down

0 comments on commit 866c01e

Please sign in to comment.