{"id":32719087,"url":"https://github.com/0pkunal/3d-volume-calculation","last_synced_at":"2025-11-02T18:03:19.172Z","repository":{"id":318554560,"uuid":"1071783887","full_name":"0PKunal/3d-Volume-Calculation","owner":"0PKunal","description":"3D Visualization and Volume calculation of f(x) = x³ - 3x + 1","archived":false,"fork":false,"pushed_at":"2025-10-07T21:29:40.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-07T22:24:34.770Z","etag":null,"topics":["python","python-3","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0PKunal.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-07T20:05:14.000Z","updated_at":"2025-10-07T21:30:42.000Z","dependencies_parsed_at":"2025-10-07T22:24:36.582Z","dependency_job_id":"7cb37a9f-ffea-42ec-aa96-4b3a8db36ffd","html_url":"https://github.com/0PKunal/3d-Volume-Calculation","commit_stats":null,"previous_names":["0pkunal/3d-volume-calculation"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/0PKunal/3d-Volume-Calculation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0PKunal%2F3d-Volume-Calculation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0PKunal%2F3d-Volume-Calculation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0PKunal%2F3d-Volume-Calculation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0PKunal%2F3d-Volume-Calculation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0PKunal","download_url":"https://codeload.github.com/0PKunal/3d-Volume-Calculation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0PKunal%2F3d-Volume-Calculation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":282332561,"owners_count":26652047,"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","status":"online","status_checked_at":"2025-11-02T02:00:06.609Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["python","python-3","python3"],"created_at":"2025-11-02T18:02:25.631Z","updated_at":"2025-11-02T18:03:19.157Z","avatar_url":"https://github.com/0PKunal.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 3D Volume Calculation\n\n[![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GitHub stars](https://img.shields.io/github/stars/0PKunal/3d-Volume-Calculation?style=social)](https://github.com/0PKunal/3d-Volume-Calculation/stargazers)\n\nA Python-based mathematical tool for calculating and visualizing the volume of solids of revolution using calculus. This project demonstrates the elegant intersection of mathematics and programming by computing volumes through symbolic integration and rendering stunning 3D visualizations of the resulting solids.\n\n\u003c/div\u003e\n\n## Table of Contents\n- [Overview](#overview)\n- [Features](#features)\n- [Mathematical Background](#mathematical-background)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Output](#output)\n- [Customization](#customization)\n- [Technical Details](#technical-details)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Overview\n\nThis project demonstrates the practical application of calculus in computing volumes of solids of revolution. It uses the **disk method** to calculate the volume when a function is rotated around the x-axis, computing the integral and generating an interactive 3D visualization of the resulting solid.\n\n**Current Implementation:**\n- **Function:** $f(x) = x^3 - 3x + 1$\n- **Rotation:** Around the x-axis\n- **Interval:** $[0, 5]$\n- **Volume Formula:** $V = \\pi \\int_{0}^{5} [f(x)]^2 \\, dx$\n\n## Features\n\n- **Symbolic Mathematics**: Uses SymPy to compute exact volume integrals symbolically before numerical evaluation\n- **Interactive 3D Visualization**: Creates beautiful, rotatable 3D surface plots of solids of revolution\n- **Parametric Surface Generation**: Generates mesh grids using polar coordinates for accurate surface representation\n- **Customizable Functions**: Easily modify the function, integration bounds, and visualization parameters\n- **High-Quality Output**: Produces professional visualizations with proper axis labels, titles, and color mapping\n- **Exact Calculation**: Leverages symbolic integration for mathematically precise results\n\n## Mathematical Background\n\nThe volume of a solid of revolution is a fundamental concept in calculus. When a continuous function $f(x)$ is rotated around the x-axis from $x = a$ to $x = b$, the volume of the resulting solid is given by:\n\n$$V = \\pi \\int_{a}^{b} [f(x)]^2 \\, dx$$\n\nThis is known as the **disk method**, which conceptually slices the solid into infinitesimally thin circular disks perpendicular to the axis of rotation. Each disk has:\n- **Radius**: $r = f(x)$\n- **Area**: $A = \\pi [f(x)]^2$\n- **Volume**: $dV = \\pi [f(x)]^2 \\, dx$\n\nIntegrating these infinitesimal volumes gives us the total volume of the solid.\n\n### For This Project\n\nGiven $f(x) = x^3 - 3x + 1$ rotated around the x-axis from $x = 0$ to $x = 5$:\n\n$$V = \\pi \\int_{0}^{5} (x^3 - 3x + 1)^2 \\, dx$$\n\nThe script uses SymPy's symbolic integration to compute this exactly, yielding:\n\n**Volume ≈ 25,221.38 cubic units**\n\n### Visualization Method\n\nThe 3D surface is generated using **parametric equations** in cylindrical coordinates:\n- **x-coordinate**: Direct linear spacing along $[0, 5]$\n- **y-coordinate**: $y = f(x) = x^3 - 3x + 1$ at each x\n- **z-coordinate**: $z = y \\cdot \\cos(\\theta)$ for rotation\n- **w-coordinate**: $w = y \\cdot \\sin(\\theta)$ for rotation\n\nWhere $\\theta \\in [0, 2\\pi]$ completes the full revolution around the x-axis.\n\n---\n\n## Installation\n\n### Prerequisites\n\n- **Python 3.7 or higher**\n- **pip** (Python package manager)\n\n### Setup\n\n1. **Clone the repository:**\n```bash\ngit clone https://github.com/0PKunal/3d-Volume-Calculation.git\n```\n\n2. **Then change the directory:**\n```bash\ncd 3d-Volume-Calculation\n```\n\n **Install required dependencies:**\n```bash\npip install numpy matplotlib sympy\n```\n\n### Dependencies\n\nThis project requires the following Python packages:\n\n| Package | Purpose |\n|---------|---------|\n| **numpy** | Numerical computations, array operations, and mesh grid generation |\n| **matplotlib** | Creating 3D plots, visualizations, and surface rendering |\n| **sympy** | Symbolic mathematics and exact integration |\n\n\u003e **Note:** If you're using Anaconda, these packages are typically pre-installed.\n\n## Usage\n\n### Basic Execution\n\nRun the script using Python:\n\n```bash\npython 3d_Volume_Calculation.py\n```\n\n## Output\n\nWhen executed, the script will:\n\n1. **Calculate the volume** using symbolic integration\n2. **Print the result** to the console with high precision\n3. **Generate and display** an interactive 3D visualization\n\n**Example Console Output:**\n```\nVolume: 25221.37902144463 cubic unit\n```\n\nThe visualization window shows the solid generated by rotating $f(x) = x^3 - 3x + 1$ around the x-axis over the interval $[0, 5]$.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"3d_Volume_Calculation.png\" alt=\"3D Volume Visualization\" width=\"500\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cem\u003eInteractive 3D visualization of the solid of revolution\u003c/em\u003e\n\u003c/p\u003e\n\n**Visualization Features:**\n- **Interactive Rotation**: Click and drag to rotate the 3D model\n- **Color Mapping**: Viridis colormap shows surface depth and structure\n- **Labeled Axes**: Clear x, y, z axis labels for spatial orientation\n- **Mathematical Title**: Displays the function and integration formula\n\n---\n\n## Customization\n\nYou can easily modify the script to calculate volumes for different functions and intervals:\n\n### Changing the Function\n\nEdit the function definition in `3d_Volume_Calculation.py`:\n\n```python\n# Define your custom function\nx = symbols('x')\nf = x**2 + 1  # Change this to your desired function\n```\n\n### Changing the Integration Interval\n\nModify the integration bounds:\n\n```python\n# Compute the volume with custom bounds\nintegral = integrate(f**2, (x, a, b))  # Change a and b\nvolume = pi * integral\n```\n\n### Adjusting Visualization\n\nCustomize the plot appearance:\n\n```python\n# Adjust resolution\nX = np.linspace(0, 5, 500)  # Increase for smoother surface\ntheta = np.linspace(0, 2*np.pi, 200)  # Increase for better circular definition\n\n# Change colormap\nax.plot_surface(X_grid, Z_grid, W_grid, cmap='plasma', alpha=0.9)  # Try 'plasma', 'inferno', 'cool'\n```\n\n---\n\n## Technical Details\n\n### Algorithm Overview\n\n1. **Symbolic Integration**: Uses SymPy to compute the exact integral symbolically\n2. **Mesh Generation**: Creates a parametric surface using NumPy meshgrid\n3. **Polar Transformation**: Converts function values to cylindrical coordinates for revolution\n4. **3D Rendering**: Matplotlib's `plot_surface` displays the interactive 3D solid\n\n### Key Libraries Used\n\n- **NumPy**: Efficient array operations and numerical mesh generation\n- **Matplotlib**: Advanced 3D plotting and interactive visualization\n- **SymPy**: Symbolic mathematics for exact integration\n\n### Computational Complexity\n\n- **Time Complexity**: O(n × m) where n is X resolution and m is theta resolution\n- **Space Complexity**: O(n × m) for mesh grid storage\n\n---\n\n## Project Structure\n\n```\n3d-Volume-Calculation/\n├── 3d_Volume_Calculation.py    # Main calculation and visualization script\n├── 3d_Volume_Calculation.png   # Sample output visualization\n├── README.md                   # This documentation file\n└── LICENSE                     # MIT License file\n```\n\n---\n\n## Contributing\n\nContributions are welcome and appreciated! Here are some ways you can contribute:\n\n### Report Issues\n- Found a bug? Open an issue with details\n- Include your Python version and error messages\n- Describe steps to reproduce the problem\n\n### Suggest Enhancements\n- New features or improvements\n- Better visualization techniques\n- Additional mathematical methods (shell method, washer method)\n- Performance optimizations\n\n### Submit Pull Requests\n- Fork the repository\n- Create a feature branch: `git checkout -b feature/your-feature`\n- Make your changes with clear, commented code\n- Test thoroughly with different functions\n- Submit a pull request with a detailed description\n\n### Ideas for Contribution\n- Add support for rotation around the y-axis\n- Implement the washer method for hollow solids\n- Create a GUI for interactive function input\n- Add animation showing the revolution process\n- Export visualizations as image files or GIFs\n- Support for multiple functions simultaneously\n\nPlease ensure any code contributions maintain the existing style and include appropriate documentation.\n\n---\n\n## License\n\nThis project is open source and available under the [MIT License](LICENSE).\n\n**MIT License** - Copyright (c) 2025 0PKunal\n\n*Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions outlined in the [LICENSE](LICENSE) file.*\n\n---\n\u003e **Note:** This README.md file was generated with the assistance of GitHub Copilot. While every effort has been made to ensure accuracy and clarity, there may still be minor errors or inconsistencies. Users are encouraged to review the content carefully and make any necessary adjustments.\n---\n\n\u003cdiv align=\"center\"\u003e\n  \u003cp\u003eMade with ❤️ by \u003ca href=\"https://github.com/0PKunal\"\u003e0PKunal\u003c/a\u003e\u003c/p\u003e\n  \u003cp\u003eIf this project helped you, please give it a ⭐️\u003c/p\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0pkunal%2F3d-volume-calculation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0pkunal%2F3d-volume-calculation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0pkunal%2F3d-volume-calculation/lists"}