{"id":25463114,"url":"https://github.com/artifact-works/geomcpp","last_synced_at":"2025-10-27T14:24:20.990Z","repository":{"id":274667487,"uuid":"923123233","full_name":"Artifact-Works/GeomCpp","owner":"Artifact-Works","description":"GeomCpp is a lightweight C++ library focused on providing fundamental geometric operations and algorithms. Offers simple and efficient API for working with basic geometric shapes, supports visualization.","archived":false,"fork":false,"pushed_at":"2025-02-16T14:31:15.000Z","size":500,"stargazers_count":1,"open_issues_count":15,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-16T15:33:00.093Z","etag":null,"topics":["cpp","cpp20","cpp20-library","geometry"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Artifact-Works.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-27T17:23:21.000Z","updated_at":"2025-02-16T14:41:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf86bc0b-34aa-481d-a1b9-343effaaa13e","html_url":"https://github.com/Artifact-Works/GeomCpp","commit_stats":null,"previous_names":["artifact-works/geomcpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FGeomCpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FGeomCpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FGeomCpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FGeomCpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Artifact-Works","download_url":"https://codeload.github.com/Artifact-Works/GeomCpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239418577,"owners_count":19635208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","cpp20-library","geometry"],"created_at":"2025-02-18T06:19:35.173Z","updated_at":"2025-10-27T14:24:20.985Z","avatar_url":"https://github.com/Artifact-Works.png","language":"C++","readme":"# GeomCpp\nGeomCpp is a lightweight C++ library focused on providing fundamental geometric operations and algorithms. Designed to offer simple and efficient tools for working with basic geometric shapes.\n\n## Features\n- **Point and Vector Representation:**\n    - Supports basic 2D and 3D points and vectors.\n    - Uses templates to handle different numeric types (e.g., ``double``, ``float``) and dimensions.\n- **Geometric Operations:**\n    - **Dot Product:** Calculates the dot product between two vectors.\n    - **Distance:** Computes the Euclidean distance between two points.\n    - **Addition and Subtraction:** Allows vector addition and subtraction.\n    - **Collinearity Check:** Determines if three 2D points are collinear.\n- **Template-Based Design:**\n    - Supports dimensional flexibility via template parameters (e.g., ``Point\u003cT, Dim\u003e`` for points of arbitrary dimensions).\n    - Leverages C++ concepts and traits to ensure type safety and proper usage of geometric operations.\n\n## Adding and Visualizing A point\n```cpp\n#include \u003ciostream\u003e\n#include \"./GeomCpp/Core/Point.hpp\"\n#include \"./GeomCpp/Visualizer/Visualizer.hpp\"\n\nnamespace gp = GeomCPP;\n\nint main()\n{\n    // Create 2D points\n    gp::Point\u003cdouble, 2\u003e p1 = {{100.1, 200.2}};\n    gp::Point\u003cdouble, 2\u003e p2 = {{400.0, 500.0}};\n\n    gp::Point\u003cdouble, 2\u003e p3 = p1 + p2;\n    std::cout \u003c\u003c \"Sum: \";\n    p3.print();\n\n    double dot_result = p1.dot(p2);\n    std::cout \u003c\u003c \"Dot product: \" \u003c\u003c dot_result \u003c\u003c \"\\n\";\n\n    double dist = p1.distance(p2);\n    std::cout \u003c\u003c \"Distance: \" \u003c\u003c dist \u003c\u003c \"\\n\";\n\n    std::cout \u003c\u003c \"Scaling p1 by 1.4: \\n\";\n    p1.scale(1.4);\n    p1.print();\n\n    using Point_2D = gp::Point\u003cdouble, 2\u003e;\n\n    std::cout \u003c\u003c \"Collinear test: \"\n              \u003c\u003c Point_2D::collinear(Point_2D({1.0, 1}), Point_2D({2.0, 2.0}), Point_2D({3.0, 3.0}))\n              \u003c\u003c \"\\n\"; // Expected output: 1 (true)\n\n    std::cout \u003c\u003c \"Coordinates of p2: \";\n    for (const auto \u0026coord : p2)\n    {\n        std::cout \u003c\u003c coord \u003c\u003c \" \";\n    }\n    std::cout \u003c\u003c std::endl;\n    gp::Visualizer vis;\n\n    vis.addPoint(p1);\n    vis.addPoint(p2);\n    vis.addPoint(p3);\n    vis.run();\n    return 0;\n}\n```\n![Screenshot_20250210_181118](https://github.com/user-attachments/assets/b4d28684-94e1-4eb2-a82e-82db12dc04f0)\n\n## Adding and Visualizing a Line\n```cpp\n#include \"../../Core/Line.hpp\"\n#include \"../../Core/Point.hpp\"\n#include \u003ciostream\u003e\n#include \"../../Visualizer/Visualizer.hpp\"\n\nnamespace gp = GeomCPP;\n\nint main()\n{\n    // Define 2D points\n    gp::Point\u003cdouble, 2\u003e p1 = {{100.0, 200.0}};\n    gp::Point\u003cdouble, 2\u003e p2 = {{400.0, 600.0}};\n    gp::Point\u003cdouble, 2\u003e p3 = {{200.0, 300.0}};\n    gp::Point\u003cdouble, 2\u003e p4 = {{500.0, 700.0}};\n    gp::Point\u003cdouble, 2\u003e p5 = {{150.0, 450.0}};\n    gp::Point\u003cdouble, 2\u003e p6 = {{350.0, 250.0}};\n    gp::Point\u003cdouble, 2\u003e p7 = {{450.0, 500.0}};\n    gp::Point\u003cdouble, 2\u003e p8 = {{600.0, 100.0}};\n\n    gp::Line\u003cdouble, 2\u003e line1(p1, p2);\n    gp::Line\u003cdouble, 2\u003e line2(p3, p4);\n    gp::Line\u003cdouble, 2\u003e line3(p5, p6);\n    gp::Line\u003cdouble, 2\u003e line4(p7, p8);\n    gp::Line\u003cdouble, 2\u003e line5(p2, p8); // Diagonal\n    gp::Line\u003cdouble, 2\u003e line6(p3, p7); \n\n    std::cout \u003c\u003c \"Line 1 Length: \" \u003c\u003c line1.length() \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c \"Line 2 Length: \" \u003c\u003c line2.length() \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c \"Line 3 Length: \" \u003c\u003c line3.length() \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c \"Line 4 Length: \" \u003c\u003c line4.length() \u003c\u003c \"\\n\";\n\n    std::cout \u003c\u003c \"Line1 parallel to Line2? \" \u003c\u003c line1.is_parallel(line2) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c \"Line3 parallel to Line4? \" \u003c\u003c line3.is_parallel(line4) \u003c\u003c \"\\n\";\n\n    gp::Point\u003cdouble, 2\u003e test_point = {{2.5, 4.0}};\n    std::cout \u003c\u003c \"Point (2.5, 4.0) on Line1? \" \u003c\u003c line1.contains(test_point) \u003c\u003c \"\\n\";\n\n    gp::Visualizer vis;\n    vis.addPoint(p1);vis.addPoint(p2);\n    vis.addPoint(p3);vis.addPoint(p4);\n    vis.addPoint(p5);vis.addPoint(p6);\n    vis.addPoint(p7);vis.addPoint(p8);\n\n    vis.addLine(p1, p2);vis.addLine(p3, p4);\n    vis.addLine(p5, p6);vis.addLine(p7, p8);\n    vis.addLine(p2, p8);vis.addLine(p3, p7);\n\n    vis.run();\n\n    return 0;\n}\n```\n![Screenshot_20250222_110755](https://github.com/user-attachments/assets/f4390381-468b-47c7-acf6-2bbdec4f7f19)\n\n## Compiling and running\nGeomCPP Requires SFML for visualization as adepencency, so make sure you have it before you run the visualizer. Running visualizer is not mandatory, you can use the ``GeomCPP`` classes as a standalone entity, in that case you wont need the SFML library.\n```bash\ng++ test.cpp -o geom_cpp -lsfml-graphics -lsfml-window -lsfml-system -std=c++20 \u0026\u0026 ./geom_cpp\n```\n## Running Tests\n``GeomCpp`` uses Google's testing framework **GTest** to run tests.\n\n### Step-by-Step Instructions\n1. **Navigate to the ``tests`` directory:**\n```sh\n    cd tests\n```\n2. **Create a build directory:**\n```sh\n    mkdir build \u0026\u0026 cd build\n```\n3. **Run CMake to configure the project:**\n```sh\n    cmake ..\n```\n## Running All Tests\n- To build all tests, you can either run:\n```sh\n    make\n```\nor\n```sh\n    make all_tests\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartifact-works%2Fgeomcpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartifact-works%2Fgeomcpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartifact-works%2Fgeomcpp/lists"}