{"id":18792356,"url":"https://github.com/kplanisphere/polar-function-graphing-bresenham","last_synced_at":"2026-04-29T08:33:58.398Z","repository":{"id":241976920,"uuid":"808358875","full_name":"KPlanisphere/polar-function-graphing-bresenham","owner":"KPlanisphere","description":"Proyecto 2 - Graficación","archived":false,"fork":false,"pushed_at":"2024-05-30T23:04:33.000Z","size":369,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T15:14:54.006Z","etag":null,"topics":["algorithm-implementation","bresenhams-algorithm","computer-graphics","cpp","data-visualization","graphing","opengl","polar-coordinates","rose-curve"],"latest_commit_sha":null,"homepage":"https://linktr.ee/planisphere.kgz","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KPlanisphere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-05-30T22:57:17.000Z","updated_at":"2024-05-30T23:04:36.000Z","dependencies_parsed_at":"2024-05-31T01:10:25.018Z","dependency_job_id":"d99535c7-74b7-4f27-8d94-2d1cb08e073d","html_url":"https://github.com/KPlanisphere/polar-function-graphing-bresenham","commit_stats":null,"previous_names":["kplanisphere/polar-function-graphing-bresenham"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KPlanisphere/polar-function-graphing-bresenham","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fpolar-function-graphing-bresenham","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fpolar-function-graphing-bresenham/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fpolar-function-graphing-bresenham/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fpolar-function-graphing-bresenham/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KPlanisphere","download_url":"https://codeload.github.com/KPlanisphere/polar-function-graphing-bresenham/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fpolar-function-graphing-bresenham/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32417857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["algorithm-implementation","bresenhams-algorithm","computer-graphics","cpp","data-visualization","graphing","opengl","polar-coordinates","rose-curve"],"created_at":"2024-11-07T21:19:37.465Z","updated_at":"2026-04-29T08:33:58.382Z","avatar_url":"https://github.com/KPlanisphere.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polar Function Graphing (Bresenham Algorithm)\n\n### Description\nThis project, completed as part of the coursework at the Benemérita Universidad Autónoma de Puebla, focuses on graphing a polar function using the Bresenham algorithm in the Code::Blocks IDE. The aim is to visualize a polar function, specifically a Rose Curve, while optimizing computational efficiency through the use of the Bresenham line algorithm.\n\n### Overview\nThe Bresenham algorithm is a precise and efficient method for generating rasterized lines using only integer calculations. It can be adapted to display circles and other curves, making it suitable for plotting polar functions with reduced computational cost.\n\n### Objectives\n- Implement and visualize a polar function using the Bresenham algorithm in OpenGL.\n- Apply learned concepts to optimize graph plotting by minimizing floating-point operations.\n- Develop an understanding of the Bresenham algorithm and its applications in computer graphics.\n\n### Key Features\n- **Initialization**: Set up the OpenGL environment and window properties.\n- **Bresenham Algorithm**: Calculate and plot points efficiently using integer calculations.\n- **Graphing Function**: Convert polar coordinates to Cartesian coordinates and plot the Rose Curve.\n- **Color Variation**: Implement a color scheme for visual distinction.\n\n### Project Structure\nThe project includes the following main components:\n\n#### Initialization\nThis function sets up the OpenGL environment, defining the color of the window and the projection parameters.\n\n```cpp\nvoid init(void) {\n    glClearColor(0.0, 0.0, 0.0, 1.0);\n    glMatrixMode(GL_PROJECTION);\n    glLoadIdentity();\n    gluOrtho2D(-200, 200, -200, 200);\n    glMatrixMode(GL_MODELVIEW);\n    glLoadIdentity();\n}\n```\n\n#### Bresenham Algorithm\n\nThis function implements the Bresenham algorithm to efficiently determine the points to be plotted for a given line segment.\n\n```cpp\nvoid Bresenham(int x0, int y0, int x1, int y1) {\n    int x, y, dx, dy, p, incE, incNE, stepx, stepy;\n    dx = (x1 - x0);\n    dy = (y1 - y0);\n    if (dy \u003c 0) {\n        dy = -dy; stepy = -1;\n    } else {\n        stepy = 1;\n    }\n    if (dx \u003c 0) {\n        dx = -dx; stepx = -1;\n    } else {\n        stepx = 1;\n    }\n    x = x0;\n    y = y0;\n    glBegin(GL_POINTS);\n    glVertex2i(x0, y0);\n    glEnd();\n    if (dx \u003e dy) {\n        p = 2 * dy - dx;\n        incE = 2 * dy;\n        incNE = 2 * (dy - dx);\n        while (x != x1) {\n            x = x + stepx;\n            if (p \u003c 0) {\n                p = p + incE;\n            } else {\n                y = y + stepy;\n                p = p + incNE;\n            }\n            glBegin(GL_POINTS);\n            glVertex2i(x, y);\n            glEnd();\n        }\n    } else {\n        p = 2 * dx - dy;\n        incE = 2 * dx;\n        incNE = 2 * (dx - dy);\n        while (y != y1) {\n            y = y + stepy;\n            if (p \u003c 0) {\n                p = p + incE;\n            } else {\n                x = x + stepx;\n                p = p + incNE;\n            }\n            glBegin(GL_POINTS);\n            glVertex2i(x, y);\n            glEnd();\n        }\n    }\n}\n``` \n\n#### Graphing Function\n\nThis function draws the graph by converting polar coordinates to Cartesian coordinates and utilizes the Bresenham algorithm to plot lines between calculated points.\n\n```cpp\nvoid dibujaGrafica() {\n    glClear(GL_COLOR_BUFFER_BIT);  // Clear the display window\n\n    GLfloat rpolar, angulo, diff;\n    GLint xt, yt, x0, y0, x1, y1, first;\n    first = 1;\n    glPointSize(1);\n    diff = 360 / 120;\n\n    for (i = 0; i \u003c 240; i++) {\n        rpolar = 6 * cos(4 * rad);  // Rose Curve formula\n        xt = rpolar * cos(rad) * 25;\n        yt = rpolar * sin(rad) * 25;\n\n        glColor3f(0.255, 0, 0.700);  // Set color\n\n        if (first == 1) {  // First point\n            x0 = xt;\n            y0 = xt;\n            x1 = xt;\n            y1 = xt;\n            first = 0;\n        } else {  // Subsequent points\n            x0 = x1;\n            y0 = y1;\n            x1 = xt;\n            y1 = yt;\n            if (i \u003e 1) {\n                Bresenham(x0, y0, x1, y1);\n            }\n        }\n        angulo = angulo + diff;\n        rad = angulo * (M_PI / 180);\n    }\n    glFlush();\n}\n```\n\n#### Main Function\n\nThis function initializes the graphics window and starts the main loop.\n\n```cpp\nint main(int argc, char** argv) {\n    glutInit(\u0026argc, argv);\n    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);\n    glutInitWindowPosition(100, 100);\n    glutInitWindowSize(400, 400);\n    glutCreateWindow(\"Curva Rosa (Bresenham)\");\n    init();\n    glutDisplayFunc(dibujaGrafica);\n    glutMainLoop();\n\n    return 0;\n}\n```\n\n### Execution\n\nThe project initializes a graphical window and plots a Rose Curve using the Bresenham algorithm. This approach reduces computational costs by minimizing floating-point operations, resulting in an efficient and accurate graph plotting.\n\n\u003cp align= \"center\"\u003e\n    \u003cimg src=\"https://github.com/KPlanisphere/binary-tree-operations/assets/60454942/f621bf61-811c-4d30-897f-2ad8147b401a\" style=\"width: 70%; height: auto;\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkplanisphere%2Fpolar-function-graphing-bresenham","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkplanisphere%2Fpolar-function-graphing-bresenham","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkplanisphere%2Fpolar-function-graphing-bresenham/lists"}