Minkowski Difference with 3D convex Polyhedrons












0















I do not know much about collision detection and I am trying to resolve 3D collisions exactly. To do so, I am using the Minkowski difference. The thing is, I am having problems calculating the difference between two shapes.



What I tried doing:
In 2D you can calculate the M. difference of 2 polygons (A and B) by looping in the edges of A finding the correct support vertex of B by using the reversed edge normal of A and then substrating the edge of A by the supporting vertex of B. And then do something similar by looping through the edges of B.



So basically, in 3D I tried doing the same thing by using triangles instead of edges. It seems to kinda work and kinda fail (here is M. difference of a cube with the same cube turned 45 degrees):
Click to view image.



As seen in the image, there is a weird hole in the middle. I don't think this is normal because we are supposed to end up with a closed shape.



Here below is my code (note that the code is very unoptimised because I'm not sure about how to choose the supporting vertices, so I don't choose, I take all of them).



Here is the class which takes care of the Minkowski stuff (if there is an //OK over the method, I'm pretty sure that it works):



#include "TransformedPolyhedron.h"
#include "Array.h"
#include "graphics/MeshLoader.h"
#include <iostream>

using namespace graphics;

namespace math
{
TransformedPolyhedron::TransformedPolyhedron(Polyhedron& polyhedron)
{
this->polyhedron = &polyhedron;
}

//OK
ArrayList<int>& TransformedPolyhedron::getIndices() const
{
return polyhedron->getIndices();
}

//OK
ArrayList<Vector3> TransformedPolyhedron::getTransformedPositions() const
{
ArrayList<Vector3>& positions = polyhedron->getPositions();
ArrayList<Vector3> result(positions.size());

for(int i=0;i<result.size();i++)
{
result[i] = transformation.transform(positions[i]);
}
return result;
}

//OK(?)
ArrayList<TriangleFace> TransformedPolyhedron::getTriangleFaces(const ArrayList<Vector3>& positions) const
{
ArrayList<int>& indices = getIndices();
ArrayList<TriangleFace> result;
for(int i=0;i<indices.size();i+=3)
{
Vector3& v1 = positions[indices[i]];
Vector3& v2 = positions[indices[i + 1]];
Vector3& v3 = positions[indices[i + 2]];
result.add(TriangleFace(v1, v2, v3));
}
return result;
}

ArrayList<Vector3> TransformedPolyhedron::getSupportingVertex(const Vector3& normal, const ArrayList<Vector3>& positions) const
{
double maxDot = normal.dot(positions[0]);
for(int i=0;i<positions.size();i++)
{
double dot = normal.dot(positions[i]);
if(dot > maxDot)
{
maxDot = dot;
}
}
ArrayList<Vector3> result;
for(int i=0;i<positions.size();i++)
{
Vector3& position = positions[i];
double dot = normal.dot(position);
if(dot >= maxDot)
{
result.add(position);
}
}
return result;
}

Polyhedron TransformedPolyhedron::minkowskiDifference(const TransformedPolyhedron& poly) const
{
ArrayList<int> resultIndices;
ArrayList<Vector3> resultPositions;

ArrayList<Vector3> thisPositions = getTransformedPositions();
ArrayList<TriangleFace> thisTriangleFaces = getTriangleFaces(thisPositions);

ArrayList<Vector3> polyPositions = poly.getTransformedPositions();
ArrayList<TriangleFace> polyTriangleFaces = poly.getTriangleFaces(polyPositions);
//this
for(int i=0;i<thisTriangleFaces.size();i++)
{
TriangleFace& triangle = thisTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = poly.getSupportingVertex(normal, polyPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}
//poly
for(int i=0;i<polyTriangleFaces.size();i++)
{
TriangleFace& triangle = polyTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = getSupportingVertex(normal, thisPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}

return Polyhedron(resultPositions, resultIndices);
}

//OK
void TransformedPolyhedron::transform(const Matrix4& transformation)
{
this->transformation = transformation;
}

//ok
GLuint TransformedPolyhedron::loadToGPU(int* amount) const
{
ArrayList<int>& indices = getIndices();
ArrayList<Vector3> positions = getTransformedPositions();
ArrayList<float> textures(positions.size()*2);
ArrayList<float> positionsArray(positions.size()*3);
for(int i=0;i<positions.size();i++)
{
positionsArray[3*i] = positions[i].getX();
positionsArray[3*i + 1] = positions[i].getY();
positionsArray[3*i + 2] = positions[i].getZ();
}
Array<float> apos(positionsArray.toArray(), positionsArray.size());
Array<int> aind(indices.toArray(), indices.size());
Array<float> atex(textures.toArray(), textures.size());
*amount = indices.size();
return MeshLoader::loadIndexedVertices(apos, atex, aind);
}
}


Thanks for helping!










share|improve this question

























  • Forgot to tag c++?

    – kabanus
    Nov 23 '18 at 20:20











  • Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

    – bcperth
    Nov 23 '18 at 23:19
















0















I do not know much about collision detection and I am trying to resolve 3D collisions exactly. To do so, I am using the Minkowski difference. The thing is, I am having problems calculating the difference between two shapes.



What I tried doing:
In 2D you can calculate the M. difference of 2 polygons (A and B) by looping in the edges of A finding the correct support vertex of B by using the reversed edge normal of A and then substrating the edge of A by the supporting vertex of B. And then do something similar by looping through the edges of B.



So basically, in 3D I tried doing the same thing by using triangles instead of edges. It seems to kinda work and kinda fail (here is M. difference of a cube with the same cube turned 45 degrees):
Click to view image.



As seen in the image, there is a weird hole in the middle. I don't think this is normal because we are supposed to end up with a closed shape.



Here below is my code (note that the code is very unoptimised because I'm not sure about how to choose the supporting vertices, so I don't choose, I take all of them).



Here is the class which takes care of the Minkowski stuff (if there is an //OK over the method, I'm pretty sure that it works):



#include "TransformedPolyhedron.h"
#include "Array.h"
#include "graphics/MeshLoader.h"
#include <iostream>

using namespace graphics;

namespace math
{
TransformedPolyhedron::TransformedPolyhedron(Polyhedron& polyhedron)
{
this->polyhedron = &polyhedron;
}

//OK
ArrayList<int>& TransformedPolyhedron::getIndices() const
{
return polyhedron->getIndices();
}

//OK
ArrayList<Vector3> TransformedPolyhedron::getTransformedPositions() const
{
ArrayList<Vector3>& positions = polyhedron->getPositions();
ArrayList<Vector3> result(positions.size());

for(int i=0;i<result.size();i++)
{
result[i] = transformation.transform(positions[i]);
}
return result;
}

//OK(?)
ArrayList<TriangleFace> TransformedPolyhedron::getTriangleFaces(const ArrayList<Vector3>& positions) const
{
ArrayList<int>& indices = getIndices();
ArrayList<TriangleFace> result;
for(int i=0;i<indices.size();i+=3)
{
Vector3& v1 = positions[indices[i]];
Vector3& v2 = positions[indices[i + 1]];
Vector3& v3 = positions[indices[i + 2]];
result.add(TriangleFace(v1, v2, v3));
}
return result;
}

ArrayList<Vector3> TransformedPolyhedron::getSupportingVertex(const Vector3& normal, const ArrayList<Vector3>& positions) const
{
double maxDot = normal.dot(positions[0]);
for(int i=0;i<positions.size();i++)
{
double dot = normal.dot(positions[i]);
if(dot > maxDot)
{
maxDot = dot;
}
}
ArrayList<Vector3> result;
for(int i=0;i<positions.size();i++)
{
Vector3& position = positions[i];
double dot = normal.dot(position);
if(dot >= maxDot)
{
result.add(position);
}
}
return result;
}

Polyhedron TransformedPolyhedron::minkowskiDifference(const TransformedPolyhedron& poly) const
{
ArrayList<int> resultIndices;
ArrayList<Vector3> resultPositions;

ArrayList<Vector3> thisPositions = getTransformedPositions();
ArrayList<TriangleFace> thisTriangleFaces = getTriangleFaces(thisPositions);

ArrayList<Vector3> polyPositions = poly.getTransformedPositions();
ArrayList<TriangleFace> polyTriangleFaces = poly.getTriangleFaces(polyPositions);
//this
for(int i=0;i<thisTriangleFaces.size();i++)
{
TriangleFace& triangle = thisTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = poly.getSupportingVertex(normal, polyPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}
//poly
for(int i=0;i<polyTriangleFaces.size();i++)
{
TriangleFace& triangle = polyTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = getSupportingVertex(normal, thisPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}

return Polyhedron(resultPositions, resultIndices);
}

//OK
void TransformedPolyhedron::transform(const Matrix4& transformation)
{
this->transformation = transformation;
}

//ok
GLuint TransformedPolyhedron::loadToGPU(int* amount) const
{
ArrayList<int>& indices = getIndices();
ArrayList<Vector3> positions = getTransformedPositions();
ArrayList<float> textures(positions.size()*2);
ArrayList<float> positionsArray(positions.size()*3);
for(int i=0;i<positions.size();i++)
{
positionsArray[3*i] = positions[i].getX();
positionsArray[3*i + 1] = positions[i].getY();
positionsArray[3*i + 2] = positions[i].getZ();
}
Array<float> apos(positionsArray.toArray(), positionsArray.size());
Array<int> aind(indices.toArray(), indices.size());
Array<float> atex(textures.toArray(), textures.size());
*amount = indices.size();
return MeshLoader::loadIndexedVertices(apos, atex, aind);
}
}


Thanks for helping!










share|improve this question

























  • Forgot to tag c++?

    – kabanus
    Nov 23 '18 at 20:20











  • Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

    – bcperth
    Nov 23 '18 at 23:19














0












0








0








I do not know much about collision detection and I am trying to resolve 3D collisions exactly. To do so, I am using the Minkowski difference. The thing is, I am having problems calculating the difference between two shapes.



What I tried doing:
In 2D you can calculate the M. difference of 2 polygons (A and B) by looping in the edges of A finding the correct support vertex of B by using the reversed edge normal of A and then substrating the edge of A by the supporting vertex of B. And then do something similar by looping through the edges of B.



So basically, in 3D I tried doing the same thing by using triangles instead of edges. It seems to kinda work and kinda fail (here is M. difference of a cube with the same cube turned 45 degrees):
Click to view image.



As seen in the image, there is a weird hole in the middle. I don't think this is normal because we are supposed to end up with a closed shape.



Here below is my code (note that the code is very unoptimised because I'm not sure about how to choose the supporting vertices, so I don't choose, I take all of them).



Here is the class which takes care of the Minkowski stuff (if there is an //OK over the method, I'm pretty sure that it works):



#include "TransformedPolyhedron.h"
#include "Array.h"
#include "graphics/MeshLoader.h"
#include <iostream>

using namespace graphics;

namespace math
{
TransformedPolyhedron::TransformedPolyhedron(Polyhedron& polyhedron)
{
this->polyhedron = &polyhedron;
}

//OK
ArrayList<int>& TransformedPolyhedron::getIndices() const
{
return polyhedron->getIndices();
}

//OK
ArrayList<Vector3> TransformedPolyhedron::getTransformedPositions() const
{
ArrayList<Vector3>& positions = polyhedron->getPositions();
ArrayList<Vector3> result(positions.size());

for(int i=0;i<result.size();i++)
{
result[i] = transformation.transform(positions[i]);
}
return result;
}

//OK(?)
ArrayList<TriangleFace> TransformedPolyhedron::getTriangleFaces(const ArrayList<Vector3>& positions) const
{
ArrayList<int>& indices = getIndices();
ArrayList<TriangleFace> result;
for(int i=0;i<indices.size();i+=3)
{
Vector3& v1 = positions[indices[i]];
Vector3& v2 = positions[indices[i + 1]];
Vector3& v3 = positions[indices[i + 2]];
result.add(TriangleFace(v1, v2, v3));
}
return result;
}

ArrayList<Vector3> TransformedPolyhedron::getSupportingVertex(const Vector3& normal, const ArrayList<Vector3>& positions) const
{
double maxDot = normal.dot(positions[0]);
for(int i=0;i<positions.size();i++)
{
double dot = normal.dot(positions[i]);
if(dot > maxDot)
{
maxDot = dot;
}
}
ArrayList<Vector3> result;
for(int i=0;i<positions.size();i++)
{
Vector3& position = positions[i];
double dot = normal.dot(position);
if(dot >= maxDot)
{
result.add(position);
}
}
return result;
}

Polyhedron TransformedPolyhedron::minkowskiDifference(const TransformedPolyhedron& poly) const
{
ArrayList<int> resultIndices;
ArrayList<Vector3> resultPositions;

ArrayList<Vector3> thisPositions = getTransformedPositions();
ArrayList<TriangleFace> thisTriangleFaces = getTriangleFaces(thisPositions);

ArrayList<Vector3> polyPositions = poly.getTransformedPositions();
ArrayList<TriangleFace> polyTriangleFaces = poly.getTriangleFaces(polyPositions);
//this
for(int i=0;i<thisTriangleFaces.size();i++)
{
TriangleFace& triangle = thisTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = poly.getSupportingVertex(normal, polyPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}
//poly
for(int i=0;i<polyTriangleFaces.size();i++)
{
TriangleFace& triangle = polyTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = getSupportingVertex(normal, thisPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}

return Polyhedron(resultPositions, resultIndices);
}

//OK
void TransformedPolyhedron::transform(const Matrix4& transformation)
{
this->transformation = transformation;
}

//ok
GLuint TransformedPolyhedron::loadToGPU(int* amount) const
{
ArrayList<int>& indices = getIndices();
ArrayList<Vector3> positions = getTransformedPositions();
ArrayList<float> textures(positions.size()*2);
ArrayList<float> positionsArray(positions.size()*3);
for(int i=0;i<positions.size();i++)
{
positionsArray[3*i] = positions[i].getX();
positionsArray[3*i + 1] = positions[i].getY();
positionsArray[3*i + 2] = positions[i].getZ();
}
Array<float> apos(positionsArray.toArray(), positionsArray.size());
Array<int> aind(indices.toArray(), indices.size());
Array<float> atex(textures.toArray(), textures.size());
*amount = indices.size();
return MeshLoader::loadIndexedVertices(apos, atex, aind);
}
}


Thanks for helping!










share|improve this question
















I do not know much about collision detection and I am trying to resolve 3D collisions exactly. To do so, I am using the Minkowski difference. The thing is, I am having problems calculating the difference between two shapes.



What I tried doing:
In 2D you can calculate the M. difference of 2 polygons (A and B) by looping in the edges of A finding the correct support vertex of B by using the reversed edge normal of A and then substrating the edge of A by the supporting vertex of B. And then do something similar by looping through the edges of B.



So basically, in 3D I tried doing the same thing by using triangles instead of edges. It seems to kinda work and kinda fail (here is M. difference of a cube with the same cube turned 45 degrees):
Click to view image.



As seen in the image, there is a weird hole in the middle. I don't think this is normal because we are supposed to end up with a closed shape.



Here below is my code (note that the code is very unoptimised because I'm not sure about how to choose the supporting vertices, so I don't choose, I take all of them).



Here is the class which takes care of the Minkowski stuff (if there is an //OK over the method, I'm pretty sure that it works):



#include "TransformedPolyhedron.h"
#include "Array.h"
#include "graphics/MeshLoader.h"
#include <iostream>

using namespace graphics;

namespace math
{
TransformedPolyhedron::TransformedPolyhedron(Polyhedron& polyhedron)
{
this->polyhedron = &polyhedron;
}

//OK
ArrayList<int>& TransformedPolyhedron::getIndices() const
{
return polyhedron->getIndices();
}

//OK
ArrayList<Vector3> TransformedPolyhedron::getTransformedPositions() const
{
ArrayList<Vector3>& positions = polyhedron->getPositions();
ArrayList<Vector3> result(positions.size());

for(int i=0;i<result.size();i++)
{
result[i] = transformation.transform(positions[i]);
}
return result;
}

//OK(?)
ArrayList<TriangleFace> TransformedPolyhedron::getTriangleFaces(const ArrayList<Vector3>& positions) const
{
ArrayList<int>& indices = getIndices();
ArrayList<TriangleFace> result;
for(int i=0;i<indices.size();i+=3)
{
Vector3& v1 = positions[indices[i]];
Vector3& v2 = positions[indices[i + 1]];
Vector3& v3 = positions[indices[i + 2]];
result.add(TriangleFace(v1, v2, v3));
}
return result;
}

ArrayList<Vector3> TransformedPolyhedron::getSupportingVertex(const Vector3& normal, const ArrayList<Vector3>& positions) const
{
double maxDot = normal.dot(positions[0]);
for(int i=0;i<positions.size();i++)
{
double dot = normal.dot(positions[i]);
if(dot > maxDot)
{
maxDot = dot;
}
}
ArrayList<Vector3> result;
for(int i=0;i<positions.size();i++)
{
Vector3& position = positions[i];
double dot = normal.dot(position);
if(dot >= maxDot)
{
result.add(position);
}
}
return result;
}

Polyhedron TransformedPolyhedron::minkowskiDifference(const TransformedPolyhedron& poly) const
{
ArrayList<int> resultIndices;
ArrayList<Vector3> resultPositions;

ArrayList<Vector3> thisPositions = getTransformedPositions();
ArrayList<TriangleFace> thisTriangleFaces = getTriangleFaces(thisPositions);

ArrayList<Vector3> polyPositions = poly.getTransformedPositions();
ArrayList<TriangleFace> polyTriangleFaces = poly.getTriangleFaces(polyPositions);
//this
for(int i=0;i<thisTriangleFaces.size();i++)
{
TriangleFace& triangle = thisTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = poly.getSupportingVertex(normal, polyPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}
//poly
for(int i=0;i<polyTriangleFaces.size();i++)
{
TriangleFace& triangle = polyTriangleFaces[i];
Vector3 normal = triangle.getNormal();
normal*=(-1);
ArrayList<Vector3> supportingVectors = getSupportingVertex(normal, thisPositions);
for(int k=0;k<supportingVectors.size();k++)
{
Vector3& supportingVector = supportingVectors[k];
for(int j=0;j<3;j++)
{
Vector3 toAdd = triangle[j] - supportingVector;

resultIndices.add(resultPositions.size());
resultPositions.add(toAdd);
}
}
}

return Polyhedron(resultPositions, resultIndices);
}

//OK
void TransformedPolyhedron::transform(const Matrix4& transformation)
{
this->transformation = transformation;
}

//ok
GLuint TransformedPolyhedron::loadToGPU(int* amount) const
{
ArrayList<int>& indices = getIndices();
ArrayList<Vector3> positions = getTransformedPositions();
ArrayList<float> textures(positions.size()*2);
ArrayList<float> positionsArray(positions.size()*3);
for(int i=0;i<positions.size();i++)
{
positionsArray[3*i] = positions[i].getX();
positionsArray[3*i + 1] = positions[i].getY();
positionsArray[3*i + 2] = positions[i].getZ();
}
Array<float> apos(positionsArray.toArray(), positionsArray.size());
Array<int> aind(indices.toArray(), indices.size());
Array<float> atex(textures.toArray(), textures.size());
*amount = indices.size();
return MeshLoader::loadIndexedVertices(apos, atex, aind);
}
}


Thanks for helping!







c++ collision-detection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 22:34









Berthur

709212




709212










asked Nov 23 '18 at 20:17









ThatGuyAgainThatGuyAgain

46




46













  • Forgot to tag c++?

    – kabanus
    Nov 23 '18 at 20:20











  • Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

    – bcperth
    Nov 23 '18 at 23:19



















  • Forgot to tag c++?

    – kabanus
    Nov 23 '18 at 20:20











  • Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

    – bcperth
    Nov 23 '18 at 23:19

















Forgot to tag c++?

– kabanus
Nov 23 '18 at 20:20





Forgot to tag c++?

– kabanus
Nov 23 '18 at 20:20













Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

– bcperth
Nov 23 '18 at 23:19





Have you read this paper dtecta.com/papers/jgt98convex.pdf ?

– bcperth
Nov 23 '18 at 23:19












1 Answer
1






active

oldest

votes


















0














Ok i found what was wrong with the algorithm, basicly i was only calculating the "translated faces" and wasn't calculating the part done by sweeping the edges, here is a paper talking about the minkowski sum and how to compute it: liris.cnrs.fr/Documents/Liris-3813.pdf (look at the part about the CVMS algorithm)



In the end for collision detection this is very bad performence-wise, so as someone pointed out in the comments, i implemented the GJK algorithm for collision detection and the EPA algorithm for collision response, works petty well.



GJK + EPA: http://hacktank.net/blog/?p=93






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452514%2fminkowski-difference-with-3d-convex-polyhedrons%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Ok i found what was wrong with the algorithm, basicly i was only calculating the "translated faces" and wasn't calculating the part done by sweeping the edges, here is a paper talking about the minkowski sum and how to compute it: liris.cnrs.fr/Documents/Liris-3813.pdf (look at the part about the CVMS algorithm)



    In the end for collision detection this is very bad performence-wise, so as someone pointed out in the comments, i implemented the GJK algorithm for collision detection and the EPA algorithm for collision response, works petty well.



    GJK + EPA: http://hacktank.net/blog/?p=93






    share|improve this answer




























      0














      Ok i found what was wrong with the algorithm, basicly i was only calculating the "translated faces" and wasn't calculating the part done by sweeping the edges, here is a paper talking about the minkowski sum and how to compute it: liris.cnrs.fr/Documents/Liris-3813.pdf (look at the part about the CVMS algorithm)



      In the end for collision detection this is very bad performence-wise, so as someone pointed out in the comments, i implemented the GJK algorithm for collision detection and the EPA algorithm for collision response, works petty well.



      GJK + EPA: http://hacktank.net/blog/?p=93






      share|improve this answer


























        0












        0








        0







        Ok i found what was wrong with the algorithm, basicly i was only calculating the "translated faces" and wasn't calculating the part done by sweeping the edges, here is a paper talking about the minkowski sum and how to compute it: liris.cnrs.fr/Documents/Liris-3813.pdf (look at the part about the CVMS algorithm)



        In the end for collision detection this is very bad performence-wise, so as someone pointed out in the comments, i implemented the GJK algorithm for collision detection and the EPA algorithm for collision response, works petty well.



        GJK + EPA: http://hacktank.net/blog/?p=93






        share|improve this answer













        Ok i found what was wrong with the algorithm, basicly i was only calculating the "translated faces" and wasn't calculating the part done by sweeping the edges, here is a paper talking about the minkowski sum and how to compute it: liris.cnrs.fr/Documents/Liris-3813.pdf (look at the part about the CVMS algorithm)



        In the end for collision detection this is very bad performence-wise, so as someone pointed out in the comments, i implemented the GJK algorithm for collision detection and the EPA algorithm for collision response, works petty well.



        GJK + EPA: http://hacktank.net/blog/?p=93







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 13 '18 at 20:33









        ThatGuyAgainThatGuyAgain

        46




        46
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452514%2fminkowski-difference-with-3d-convex-polyhedrons%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python