Skip to content

MerlinLaboratory/Poly2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poly2d

Library to manage 2D convex polygons.

Requires:

Example of usage:

    // entering two new polygons
    std::vector<Eigen::Vector2d> triangle{ Eigen::Vector2d(0.0,0.0), Eigen::Vector2d(2.0,0.0), Eigen::Vector2d(0.0,1.0)},
                                 square{ Eigen::Vector2d(1.0,-1.0), Eigen::Vector2d(3.0,-1.0), Eigen::Vector2d(3.0,1.0), Eigen::Vector2d(1.0,1.0)};
    Poly2d t = Poly2d(triangle), s = Poly2d(square);
    
    // discretized circle
    std::vector<Eigen::Vector2d> circle;
    for(double theta = 0; theta < 2*M_PI; theta += .05 * M_PI) circle.push_back(.1 * Eigen::Vector2d(cos(theta), sin(theta)));
    Poly2d c = Poly2d(circle);
    
    // print out given polygons
    std::cout << t << std::endl << std::endl << s << std::endl << std::endl << c << std::endl << std::endl;
      
    // testing
    Poly2d x = t.MinkowskiSum(c); std::cout << x << std::endl << std::endl;
    Poly2d y = s.Intersection(x); std::cout << y << std::endl << std::endl;

Result: untitled

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published