Code Monkey home page Code Monkey logo

convexhull-3d-implementation-of-incremental-convexhull-algorithm's Issues

about float

It is not recommended to compare floating point numbers with ==

Wrong usage of unordered map

In case you have a hash collision when computing the hash of the pair of points, you will overwrite existing entries. Instead of using the hash as a key, you should use the actual pair, and use an associated hash function, ie:

    struct PointHash
    {
      size_t operator()(Point3D a) const
      {
        return std::hash<double>{}(a.x) ^ std::hash<double>{}(a.y) ^ std::hash<double>{}(a.z);
      }
    };

    struct EdgeEndpoints
    {
      Point3D p1;
      Point3D p2;

      constexpr bool operator==(const EdgeEndpoints&) const = default;
      constexpr bool operator!=(const EdgeEndpoints&) const = default;
    };

    struct EdgeEndpointHash
    {
      size_t operator()(EdgeEndpoints const& a) const
      {
        return PointHash{}(a.p1) ^ PointHash{}(a.p2);
      }
    };

    std::unordered_map<EdgeEndpoints, Edge*, EdgeEndpointHash> map_edges;

Also, please do not convert to string when computing hashes.

the convexHull is not computed correctly

int MinimumZoneFitPlane(const Point* pointsIn, int lengthIn, PlaneKernel* outLseg)
{
ConvexHull hull(pointsIn, lengthIn);
std::list faces = hull.GetFaces();
std::vector vertexs = hull.GetVertices();
std::vector pointT(vertexs.size());
for (int i = 0; i < vertexs.size(); i++) {
pointT[i].x = vertexs[i].x;
pointT[i].y = vertexs[i].y;
pointT[i].z = vertexs[i].z;
}

std::string filePath = "D:/CMM/PlanePointsVertex.csv";
WritePointsCSV(pointT.data(), pointT.size(), filePath.c_str());

return Geom3DError::OK;

}
The above is the call code for computing the 3D convex hull, the result is not correct;
PlanePoints.csv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.