{"id":26190859,"url":"https://github.com/codingabi/3drotation","last_synced_at":"2026-04-25T01:33:05.351Z","repository":{"id":42045403,"uuid":"482067054","full_name":"codingABI/3dRotation","owner":"codingABI","description":"A rotating 3d object on an Arduino Uno/Nano with a SSD1306 OLED 128x64 pixel display","archived":false,"fork":false,"pushed_at":"2024-12-31T15:50:43.000Z","size":683,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-31T16:29:56.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codingABI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2022-04-15T19:42:28.000Z","updated_at":"2024-12-31T15:50:47.000Z","dependencies_parsed_at":"2024-12-31T16:37:55.566Z","dependency_job_id":null,"html_url":"https://github.com/codingABI/3dRotation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingABI%2F3dRotation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingABI%2F3dRotation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingABI%2F3dRotation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingABI%2F3dRotation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingABI","download_url":"https://codeload.github.com/codingABI/3dRotation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243136060,"owners_count":20241989,"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":[],"created_at":"2025-03-12T00:58:24.410Z","updated_at":"2025-12-26T02:14:59.563Z","avatar_url":"https://github.com/codingABI.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 3dRotation\nA rotating 3d object on an Arduino Uno/Nano with a SSD1306 OLED 128x64 pixel display.\n\n![captured display sequence](/assets/images/Capture.gif) \n\nSimulation https://wokwi.com/projects/329034737849991764\n\nVideo https://www.youtube.com/watch?v=705kT8A-B_I\n\n## Used 3D-Object\n![default 3d object](/assets/images/3dObject.svg)\n\n## Points\n| Point | X | Y | Z |\n| --- | :---: | :---: | :---: |\n| P1 | - 32 | 32 | 32 |\n| P2 | 32 | 32 | 32 |\n| P3 | 32 | -32 | 32 |\n| P4 | - 32 | -32 | 32 |\n| P5 | - 32 | 32 | -32 |\n| P6 | 32 | 32 | -32 |\n| P7 | 32 | -32 | -32 |\n| P8 | - 32 | -32 | -32 |\n| P9 | 0 | 96 | 0 |\n| P10 | 0 | -96 | 0 |\n\n## Inner/Outer\nTo define which side of a polygon is inner or outer, all polygons (triangles or quadrangles) are ordered counterclockwise. These information will be used to detect which polygon is visible and needs to be drawn on screen or not. \n\nFor example: The order for the polygon, spanned by points P1 to P4, is **P4, P3, P2, P1**\n\n![ordered quadrangles](/assets/images/OrderedQuadrangle.svg)\n\n## Triangles:\n| Nr | Ordered points |\n| --- | --- |\n| 0 | P1, P2, P9 |\n| 1 | P6, P5, P9 |\n| 2 | P2, P6, P9 |\n| 3 | P5, P1, P9 |\n| 4 | P3, P4, P10 |\n| 5 | P4, P8, P10 |\n| 6 | P8, P7, P10 |\n| 7 | P7, P3, P10 |\n\n## Quadrangles:\n| Nr | Ordered points |\n| --- | --- |\n| 0 | P4, P3, P2, P1 |\n| 1 | P5, P6, P7, P8 |\n| 2 | P2, P3, P7, P6 |\n| 3 | P4, P1, P5, P8 |\n\n## Hide backsides\nTo detect which polygon is visible and needs to be drawn on screen or not, the order of the points spanning the polygon is checked. If the points are ordered  counterclockwise, the polygon will be drawn. If the order is clockwise, the polygon is invisible and will not be drawn.\n\nThe following figure shows an example (Green = counterclockwise =\u003e Visible, frontside, Red = clockwise =\u003e Invisible, backside). To keep it simple, only the orders for the quadrangles are marked in the figure: \n\n![detect backsides](/assets/images/DetectBacksides.svg)\n\n## Overlapping objects\nFor simple convex objects like the default 3d object in this project, which has no overlapping parts, drawing only the outer lines without filling the polygons is sufficient and the order in which the polygons are rendered does not matter.  \n\nWhen multiple objects overlaps or an object overlaps itself, we need to fill the polygons (as we have only black and white, we fill with black) and the order in which the polygons are rendered plays an important role. Since only 2KByte RAM is available on an ATMEGA328 microcontroller, a z-buffer is not an option. To allow at least simple overlapping objects, all polygons are sorted by their minimal z-values and displayed by increasing z-values. Glitches are possible due large polygons or perspective distortion.\n\nOrdered display list:\n| Display order position | Polygon type | Nr | Maximal z-value | Minimal z-value |\n| ---: | --- | :---: | :---: | :---: |\n| 0 | Quadrangle | 1 | -32 | -32 |\n| 1 | Triangle | 1 | 0 | -32 |\n| 2 | Triangle | 6 | 0 | -32 |\n| 3 | Triangle | 2 | 32 | -32 |\n| 4 | Triangle | 3 | 32 | -32 |\n| 5 | Triangle | 5 | 32 | -32 |\n| 6 | Triangle | 7 | 32 | -32 |\n| 7 | Quadrangle | 2 | 32 | -32 |\n| 8 | Quadrangle | 3 | 32 | -32 |\n| 9 | Triangle | 0 | 32 | 0 |\n| 10 | Triangle | 4 | 32 | 0 |\n| 11 | Quadrangle | 0 | 32 | 32 |\n\nHere is an example for a wrong display order, which can not be solved by z-value sorting. To solve this problem, the large side-quadrangles need to be split into smaller polygons.\n\n![glitch example](/assets/images/glitch.png) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingabi%2F3drotation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingabi%2F3drotation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingabi%2F3drotation/lists"}