{"id":19036457,"url":"https://github.com/chizuru-yamauchi/Solar_System_Visualizer_Animation_Application","last_synced_at":"2026-05-06T00:30:21.325Z","repository":{"id":244983142,"uuid":"813869174","full_name":"chizuru-nina-yamauchi/Solar_System_Visualizer_Animation_Application","owner":"chizuru-nina-yamauchi","description":"This application visualize and animate the solar system with SMFL and postgreSQL","archived":false,"fork":false,"pushed_at":"2024-06-18T15:12:37.000Z","size":1759,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T05:41:55.865Z","etag":null,"topics":["clion","cmake","postgresql","pqxx","smfl"],"latest_commit_sha":null,"homepage":"","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/chizuru-nina-yamauchi.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-06-11T22:49:08.000Z","updated_at":"2024-06-18T15:32:12.000Z","dependencies_parsed_at":"2024-06-18T20:56:32.409Z","dependency_job_id":"e3f97d95-61be-4d49-9b23-12b5a1862fdd","html_url":"https://github.com/chizuru-nina-yamauchi/Solar_System_Visualizer_Animation_Application","commit_stats":null,"previous_names":["chizuru-nina-yamauchi/solar_system_visualizer_animation_application"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chizuru-nina-yamauchi%2FSolar_System_Visualizer_Animation_Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chizuru-nina-yamauchi%2FSolar_System_Visualizer_Animation_Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chizuru-nina-yamauchi%2FSolar_System_Visualizer_Animation_Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chizuru-nina-yamauchi%2FSolar_System_Visualizer_Animation_Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chizuru-nina-yamauchi","download_url":"https://codeload.github.com/chizuru-nina-yamauchi/Solar_System_Visualizer_Animation_Application/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093145,"owners_count":19746776,"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":["clion","cmake","postgresql","pqxx","smfl"],"created_at":"2024-11-08T21:54:31.341Z","updated_at":"2026-05-06T00:30:21.233Z","avatar_url":"https://github.com/chizuru-nina-yamauchi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solar_System_Visualization\n\n\n## Project Description\nThis project is a visualization of the solar system using C++, SFML, PostgreSQL to learn C++ programming, graphics rendering, and database integration. \nThe program renders the planets of the solar system and displays information about them, such as name, radius, and distance from the sun. \nIt uses SFML for graphics rendering and PostgreSQL for data storage.\n\n## Setup Instructions\nTo run this application, you'll need:\nC++ compiler(g++ or clang++)\nSFML library\nPostgreSQL library(pqxx)\n\nInstalling SFML\nIf you haven't installed SFML library, you can install it using your package manager. For example, on Ubuntu:\n```bash\nsudo apt-get update\nsudo apt-get install libsfml-dev\n```\n\nInstalling PostgreSQL(pqxx)\nIf you haven't installed PostgreSQL library, you can install it using your package manager. For example, on Ubuntu:\n```bash\nsudo apt-get update\nsudo apt-get install libpqxx-dev\n```\n\n### How it Works\nThe program visualizes the solar system using SFML for graphics rendering and PostgreSQL for data storage. Here's how it works:\n\n1.**Initialization:**\n\nThe program initializes SFML for graphics rendering and PostgreSQL for data storage.\n\n2.**Database Connection:**\n\nThe program connects to the PostgreSQL database to retrieve data about the solar system.\n\n3.**Rendering Planets:**\n\nThe program renders the planets of the solar system using SFML graphics.\n\n4.**Displaying Information:**\n\nThe program displays information about the planets, such as name, radius, and distance from the sun.\n\n5.**Event Handling:**\n\nThe program continuously polls for SFML events.\n\n6.**Main Loop:**\n\nThe main loop of the program clears the screen, renders the planets, updates the display, and adds a delay to control the frame rate.\n\n### Setting up the Database\nTo set up the PostgreSQL database, you can use the provided SQL script to create the necessary tables and insert data. Run the following command to create the database and tables:\n```bash\nsudo -u postgres psql\nCREATE DATABASE database_name;\n\\c database_name\n```\n\nConnect to the database on CLion.\n\nCreate the tables and insert data using the console.sql file:\n\nconsole.sql\n```bash\nCREATE TABLE planets (\nname VARCHAR PRIMARY KEY,\nradius FLOAT,\ndistance FLOAT,\norbit_speed FLOAT,\nrotation_speed FLOAT,\ncolor INTEGER,\nposition_x FLOAT,\nposition_y FLOAT\n);\n\n\n\nINSERT INTO planets (name, radius, distance, orbit_speed, rotation_speed, color, position_x, position_y) VALUES\n('Sun', 30.0, 0.0, 0.0, 0.0, 0xffff00, 400.0, 300.0),\n('Mercury', 2.44, 57.91, 4.74, 10.83, 0xaaaaaa, 400.0 + 57.91 * cos(0.0), 300.0 - 57.91 * sin(0.0)),\n('Venus', 6.05, 108.2, 3.5, 6.52, 0xffd700, 400.0 + 108.2 * cos(2 * PI() / 8 * 1), 300.0 - 108.2 * sin(2 * PI() / 8 * 1)),\n('Earth', 6.37, 149.6, 2.98, 7.92, 0x0000ff, 400.0 + 149.6 * cos(2 * PI() / 8 * 2), 300.0 - 149.6 * sin(2 * PI() / 8 * 2)),\n('Mars', 3.39, 227.9, 2.41, 4.05, 0xff4500, 400.0 + 227.9 * cos(2 * PI() / 8 * 3), 300.0 - 227.9 * sin(2 * PI() / 8 * 3)),\n('Jupiter', 69.9, 778.3, 1.31, 12.6, 0xffa500, 400.0 + 778.3 * cos(2 * PI() / 8 * 4), 300.0 - 778.3 * sin(2 * PI() / 8 * 4)),\n('Saturn', 58.2, 1427, 0.97, 9.87, 0xffff00, 400.0 + 1427 * cos(2 * PI() / 8 * 5), 300.0 - 1427 * sin(2 * PI() / 8 * 5)),\n('Uranus', 25.4, 2871, 0.68, 6.49, 0x00ffff, 400.0 + 2871 * cos(2 * PI() / 8 * 6), 300.0 - 2871 * sin(2 * PI() / 8 * 6)),\n('Neptune', 24.6, 4495, 0.54, 5.43, 0x0000ff, 400.0 + 4495 * cos(2 * PI() / 8 * 7), 300.0 - 4495 * sin(2 * PI() / 8 * 7));\n\n```\n\n## Project Structure\nThe project directory contains the following files:\n\n1.**main.cpp:**\n2.**Database.cpp:**\n3.**Database.hpp:**\n4.**Planet.cpp:**\n5.**Planet.hpp:**\n6.**CMakeLists.txt:**\n7.**console.sql:**\n\n#### Running the Application\n\nAfter installing the required libraries, navigate to the project directory and build the application using CMake:\n```bash\n\nmkdir build\ncd build\ncmake ..\nmake\n# Set the DB_CONNECTION_STRING environment variable to connect to the database\nexport DB_CONNECTION_STRING=\"dbname=your_database_name user=your_username password=your_password hostaddr=your_hostaddress port=your_port_number\" \n# Run the application\n./Solar_System_Visualization\n```\n![pic1](./pics/pic1.png) \n\n## Update the data to include all the planets in the screen\n\nconsole.sql\n```bash\n\nINSERT INTO planets (name, radius, distance, orbit_speed, rotation_speed, color, position_x, position_y) VALUES\n ('Sun', 30.0, 0.0, 0.0, 0.0, 0xffff00, 400.0, 300.0),\n ('Mercury', 2.44, 57.91, 4.74, 10.83, 0xaaaaaa, 400.0 + 57.91 * cos(0.0), 300.0 - 57.91 * sin(0.0)),\n ('Venus', 6.05, 108.2, 3.5, 6.52, 0xffd700, 400.0 + 108.2 * cos(2 * PI() / 8 * 1), 300.0 - 108.2 * sin(2 * PI() / 8 * 1)),\n ('Earth', 6.37, 149.6, 2.98, 7.92, 0x0000ff, 400.0 + 149.6 * cos(2 * PI() / 8 * 2), 300.0 - 149.6 * sin(2 * PI() / 8 * 2)),\n ('Mars', 3.39, 227.9, 2.41, 4.05, 0xff4500, 400.0 + 227.9 * cos(2 * PI() / 8 * 3), 300.0 - 227.9 * sin(2 * PI() / 8 * 3)),\n ('Jupiter', 69.9, 778.3, 1.31, 12.6, 0xffa500, 400.0 + (778.3/10) * cos(2 * PI() / 8 * 4), 300.0 - (778.3/10) * sin(2 * PI() / 8 * 4)),\n ('Saturn', 58.2, 1427, 0.97, 9.87, 0xffff00, 400.0 + (1427/10) * cos(2 * PI() / 8 * 5), 300.0 - (1427/10) * sin(2 * PI() / 8 * 5)),\n ('Uranus', 25.4, 2871, 0.68, 6.49, 0x00ffff, 400.0 + (2871/10) * cos(2 * PI() / 8 * 6), 300.0 - (2871/10) * sin(2 * PI() / 8 * 6)),\n ('Neptune', 24.6, 4495, 0.54, 5.43, 0x0000ff, 400.0 + (4495/10) * cos(2 * PI() / 8 * 7), 300.0 - (4495/10) * sin(2 * PI() / 8 * 7));\n \n```\n\n\n![pic2](./pics/pic2.png)\n\n## Deubgging the issue updating the position of the planets, orbiting around the sun function\nAfter solving the issue of the size of the planets, the distance, and especially the updating the position of the planets(orbiting around the sun function), the final result is as follows:\n\n![pic3](./pics/pic3.png)\n\n![pic4](./pics/pic4.png)\n\n![pic5](./pics/pic5.png)\n\n** On the console, we can see the data of the planets, such as name, orbit speed, rotation speed, position x, and position y. **\n\n![pic6](./pics/pic6.png)\n\n![pic7](./pics/pic7.png)\n\n\n\n## Disclaimer\n\nPlease note that while the data used for the planets (such as radius, distance from the sun, orbit speed, and rotation speed) is based on real-world data, the positions of the planets in this application do not represent their real-world positions. The positions are calculated for the purpose of visualization in the application and are based on a simplified model where the orbits are circular and all in the same plane. In reality, the orbits of the planets are elliptical and inclined at different angles.\n\nFurthermore, the distances and sizes of the planets have been scaled down significantly to fit within the window of the application. In reality, the distances between the planets and their sizes vary greatly.\n\nTherefore, while this application provides a fun and interactive way to learn about the solar system, it should not be used as a source of accurate scientific information about the positions or movements of the planets.\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchizuru-yamauchi%2FSolar_System_Visualizer_Animation_Application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchizuru-yamauchi%2FSolar_System_Visualizer_Animation_Application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchizuru-yamauchi%2FSolar_System_Visualizer_Animation_Application/lists"}