# mathhunt Library
FastMath is a lightweight Python library designed for quick and efficient mathematical computations. It provides functions for calculating the volume and area of various geometric shapes, as well as distances between points in a Cartesian coordinate system.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Volume Calculation](#volume-calculation)
- [Area Calculation](#area-calculation)
- [Distance Calculation](#distance-calculation)
- [Mathematical function](#mathematical-function)
- [License](#license)
## Features
- **Volume Calculations**: Calculate the volume of shapes like cubes, spheres, cylinders, and more.
- **Area Calculations**: Calculate the area of shapes such as circles, triangles, rectangles, and polygons.
- **Distance Calculations**: Compute distances between points in a Cartesian coordinate system.
- **Error Handling**: Comprehensive error handling to ensure valid input types and values.
- **Mathematical Functions**: Use all mathematical functions required.
## Installation
**pip install fastmath**
## Usage
You should import module that you need to use from fastmath
For example you need to use sinus function. You should situate
```from mathhunt.functions import sinus```
^ ^
Where | |
**module** **function**
- - ## volume-calculation
- - - The volume function calculates the volume of various 3D shapes based on the provided shape type and corresponding metrics. It supports multiple geometric shapes and ensures input validation for accurate calculations.
**Parameters**
```*args (float)```: A variable-length argument list representing the necessary metrics for the specified shape (e.g., radius, height, side length). The number of arguments required depends on the shape type.
```type (str)```: A string that specifies the type of shape for which the volume is to be calculated. Supported types include:
'parallelepiped'
'cube'
'cylinder'
'sphere'
'cone'
'pyramid'
'tetrahedron'
'octahedron'
'icosahedron'
Returns
float: The calculated volume of the specified shape.
Raises
TypeError:
If any of the input metrics (*args) are not numbers (either int or float).
If the type parameter is not a string.
ValueError:
If the specified shape type is invalid (not one of the supported types).
If the number of arguments does not match the expected count for the specified shape type.
If any of the provided metrics are non-positive (less than or equal to zero).
**Examples of usage**
"""Calculate the volume of a cube with side length 3"""
volume_cube = volume(3, type='cube') # Returns: 27.0
"""Calculate the volume of a cylinder with radius 2 and height 5"""
volume_cylinder = volume(2, 5, type='cylinder') # Returns: 25.12
"""Calculate the volume of a sphere with radius 4"""
volume_sphere = volume(4, type='sphere') # Returns: 268.08
"""Invalid usage example
volume_invalid = volume(2, 3, type='invalid_shape')
Raises ValueError"""
- - ## area-calculation
- - - The square function calculates the area of various 2D shapes based on the specified shape type and corresponding metrics. This function is designed to handle multiple geometric shapes and includes robust input validation for accurate area calculations.
**Parameters**
```*args (float):``` A variable-length argument list that represents the necessary metrics for the specified shape (e.g., side lengths, radius). The number of arguments required varies depending on the shape type.
```type (str):``` A string that specifies the type of shape for which the area is to be calculated. Supported types include:
'quadrate'
'rectangle'
'triangle_h' (triangle with base and height)
'triangle_s' (triangle with three sides)
'circle'
'trapezoid'
'rhombus'
'parallelogram'
'sector'
'ellipse'
'polygon'
'sphere' (note: typically, spheres are 3D; area may refer to the surface area calculation)
Returns
float: The function returns the calculated area of the specified shape.
Raises
TypeError:
If any of the input metrics (*args) are not numeric (i.e., not of type int or float).
If the type parameter is not a string.
ValueError:
If the specified shape type is invalid (not one of the recognized types).
If the number of provided arguments does not match the expected count for the specified shape type.
If any of the provided metrics are non-positive (i.e., less than or equal to zero).
**Example of usage**
"""Calculate the area of a square with side length 4"""
area_square = square(4, type='quadrate') # Expected output: 16.0
"""Calculate the area of a rectangle with width 3 and height 5"""
area_rectangle = square(3, 5, type='rectangle') # Expected output: 15.0
"""Calculate the area of a triangle with base 4 and height 3"""
area_triangle_h = square(4, 3, type='triangle_h') # Expected output: 6.0
"""Calculate the area of a circle with radius 2"""
area_circle = square(2, type='circle') # Expected output: 12.56
"""Invalid usage example
area_invalid = square(3, type='invalid_shape')
This will raise ValueError"""
- - ## distance-calculation
- - - **Function: distance**
Calculates various types of distances based on the specified type and dimension.
**Parameters**
```*args (float):``` Coordinates or parameters required for distance calculation.
```type (str):``` The type of distance to calculate. Supported types include:
'dist_points'
'dist_point_line'
'dist_point_plane'
'dist_par_lines'
'dist_par_planes'
'dist_vectors'
'dist_manhattan'
'dist_cos'
'dist_Chebyshev'
dimension (str): The dimension of the space in which to calculate the distance. Acceptable values are:
'2d'
'3d'
'euclid'
Returns
float: The calculated distance based on the specified type and dimension.
Raises
TypeError: If any of the arguments are not numeric, or if type or dimension are not strings.
ValueError: If the type or dimension is invalid.
**Example of usage**
"""Calculate distance between two points in 2D"""
dist = distance(0, 0, 3, 4, type='dist_points', dimension='2d') # Output: 5.0
"""Calculate Manhattan distance in 3D"""
manhattan_dist = distance(1, 2, 3, 4, 5, 6, type='dist_manhattan', dimension='3d') # Output: 9.0
**Function: circumference**
Calculates the circumference of a circle.
Parameters
```r (float):``` The radius of the circle.
Returns
float: The calculated circumference of the circle.
Raises
TypeError: If the radius is not a number.
**Example of usage**
"""Calculate the circumference of a circle with radius 5"""
circ = circumference(5) # Output: 31.400000000000002
Here's an explanation for the distance, circumference, arc_length, and vector_length functions from your FastMath library. This documentation will help users understand the purpose, parameters, return values, and potential exceptions raised by each function.
Function: distance
Calculates various types of distances based on the specified type and dimension.
Parameters
*args (float): Coordinates or parameters required for distance calculation.
type (str): The type of distance to calculate. Supported types include:
'dist_points'
'dist_point_line'
'dist_point_plane'
'dist_par_lines'
'dist_par_planes'
'dist_vectors'
'dist_manhattan'
'dist_cos'
'dist_Chebyshev'
dimension (str): The dimension of the space in which to calculate the distance. Acceptable values are:
'2d'
'3d'
'euclid'
Returns
float: The calculated distance based on the specified type and dimension.
Raises
TypeError: If any of the arguments are not numeric, or if type or dimension are not strings.
ValueError: If the type or dimension is invalid.
Example Usage
python
Копіювати код
# Calculate distance between two points in 2D
dist = distance(0, 0, 3, 4, type='dist_points', dimension='2d') # Output: 5.0
# Calculate Manhattan distance in 3D
manhattan_dist = distance(1, 2, 3, 4, 5, 6, type='dist_manhattan', dimension='3d') # Output: 9.0
Function: circumference
Calculates the circumference of a circle.
Parameters
r (float): The radius of the circle.
Returns
float: The calculated circumference of the circle.
Raises
TypeError: If the radius is not a number.
Example Usage
python
Копіювати код
# Calculate the circumference of a circle with radius 5
circ = circumference(5) # Output: 31.400000000000002
**Function: arc_length**
Calculates the length of an arc of a circle.
Parameters
```r (float):``` The radius of the circle.
```rad (float):``` The angle in radians.
Returns
float: The calculated arc length.
Raises
TypeError: If either r or rad is not a number.
ValueError: If the angle is out of the valid range.
**Example of usage**
"""Calculate the length of an arc with radius 10 and angle π/2"""
arc = arc_length(10, 1.5708) # Output: 15.707999999999998
**Function: vector_length**
Calculates the length of a vector.
Parameters
```*args (float):``` The components of the vector.
```dimension (str):``` The dimension of the vector, either '2d' or '3d'.
Returns
float: The calculated length of the vector.
Raises
TypeError: If any arguments are not valid numbers or if dimension is not a string.
ValueError: If dimension is invalid.
**Example of usage**
"""Calculate the length of a 2D vector (3, 4)"""
vec_length_2d = vector_length(3, 4, dimension='2d') # Output: 5.0
"""Calculate the length of a 3D vector (1, 2, 2)"""
vec_length_3d = vector_length(1, 2, 2, dimension='3d') # Output: 3.0
- - ## mathematical-function
- - - Docs for that module will be soon.
Raw data
{
"_id": null,
"home_page": "https://github.com/Matvei-Antipov/mathhunt-0.1.0.git",
"name": "mathhunt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "math, calculations",
"author": "Matvei Antipov",
"author_email": "Matvei Antipov <matveiantipov2007@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/9f/f1/c1f1d9c5ad45a9cc9164b088a47e8831a007568092f60f0a4597dbd2f402/mathhunt-0.2.1.tar.gz",
"platform": null,
"description": "# mathhunt Library\r\n\r\nFastMath is a lightweight Python library designed for quick and efficient mathematical computations. It provides functions for calculating the volume and area of various geometric shapes, as well as distances between points in a Cartesian coordinate system.\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n - [Volume Calculation](#volume-calculation)\r\n - [Area Calculation](#area-calculation)\r\n - [Distance Calculation](#distance-calculation)\r\n - [Mathematical function](#mathematical-function)\r\n- [License](#license)\r\n\r\n## Features\r\n\r\n- **Volume Calculations**: Calculate the volume of shapes like cubes, spheres, cylinders, and more.\r\n- **Area Calculations**: Calculate the area of shapes such as circles, triangles, rectangles, and polygons.\r\n- **Distance Calculations**: Compute distances between points in a Cartesian coordinate system.\r\n- **Error Handling**: Comprehensive error handling to ensure valid input types and values.\r\n- **Mathematical Functions**: Use all mathematical functions required.\r\n\r\n## Installation\r\n\r\n**pip install fastmath**\r\n\r\n## Usage\r\n\r\nYou should import module that you need to use from fastmath\r\n\r\nFor example you need to use sinus function. You should situate \r\n\r\n```from mathhunt.functions import sinus```\r\n ^ ^\r\nWhere | |\r\n **module** **function** \r\n\r\n- - ## volume-calculation\r\n\r\n- - - The volume function calculates the volume of various 3D shapes based on the provided shape type and corresponding metrics. It supports multiple geometric shapes and ensures input validation for accurate calculations.\r\n\r\n**Parameters**\r\n```*args (float)```: A variable-length argument list representing the necessary metrics for the specified shape (e.g., radius, height, side length). The number of arguments required depends on the shape type.\r\n\r\n```type (str)```: A string that specifies the type of shape for which the volume is to be calculated. Supported types include:\r\n\r\n'parallelepiped'\r\n'cube'\r\n'cylinder'\r\n'sphere'\r\n'cone'\r\n'pyramid'\r\n'tetrahedron'\r\n'octahedron'\r\n'icosahedron'\r\nReturns\r\nfloat: The calculated volume of the specified shape.\r\nRaises\r\nTypeError:\r\n\r\nIf any of the input metrics (*args) are not numbers (either int or float).\r\nIf the type parameter is not a string.\r\nValueError:\r\n\r\nIf the specified shape type is invalid (not one of the supported types).\r\nIf the number of arguments does not match the expected count for the specified shape type.\r\nIf any of the provided metrics are non-positive (less than or equal to zero).\r\n\r\n**Examples of usage**\r\n\r\n\"\"\"Calculate the volume of a cube with side length 3\"\"\"\r\nvolume_cube = volume(3, type='cube') # Returns: 27.0\r\n\r\n\"\"\"Calculate the volume of a cylinder with radius 2 and height 5\"\"\"\r\nvolume_cylinder = volume(2, 5, type='cylinder') # Returns: 25.12\r\n\r\n\"\"\"Calculate the volume of a sphere with radius 4\"\"\"\r\nvolume_sphere = volume(4, type='sphere') # Returns: 268.08\r\n\r\n\"\"\"Invalid usage example\r\nvolume_invalid = volume(2, 3, type='invalid_shape')\r\nRaises ValueError\"\"\"\r\n\r\n- - ## area-calculation\r\n- - - The square function calculates the area of various 2D shapes based on the specified shape type and corresponding metrics. This function is designed to handle multiple geometric shapes and includes robust input validation for accurate area calculations.\r\n\r\n**Parameters**\r\n```*args (float):``` A variable-length argument list that represents the necessary metrics for the specified shape (e.g., side lengths, radius). The number of arguments required varies depending on the shape type.\r\n\r\n```type (str):``` A string that specifies the type of shape for which the area is to be calculated. Supported types include:\r\n\r\n'quadrate'\r\n'rectangle'\r\n'triangle_h' (triangle with base and height)\r\n'triangle_s' (triangle with three sides)\r\n'circle'\r\n'trapezoid'\r\n'rhombus'\r\n'parallelogram'\r\n'sector'\r\n'ellipse'\r\n'polygon'\r\n'sphere' (note: typically, spheres are 3D; area may refer to the surface area calculation)\r\nReturns\r\nfloat: The function returns the calculated area of the specified shape.\r\nRaises\r\nTypeError:\r\n\r\nIf any of the input metrics (*args) are not numeric (i.e., not of type int or float).\r\nIf the type parameter is not a string.\r\nValueError:\r\n\r\nIf the specified shape type is invalid (not one of the recognized types).\r\nIf the number of provided arguments does not match the expected count for the specified shape type.\r\nIf any of the provided metrics are non-positive (i.e., less than or equal to zero).\r\n\r\n**Example of usage**\r\n\r\n\"\"\"Calculate the area of a square with side length 4\"\"\"\r\narea_square = square(4, type='quadrate') # Expected output: 16.0\r\n\r\n\"\"\"Calculate the area of a rectangle with width 3 and height 5\"\"\"\r\narea_rectangle = square(3, 5, type='rectangle') # Expected output: 15.0\r\n\r\n\"\"\"Calculate the area of a triangle with base 4 and height 3\"\"\"\r\narea_triangle_h = square(4, 3, type='triangle_h') # Expected output: 6.0\r\n\r\n\"\"\"Calculate the area of a circle with radius 2\"\"\"\r\narea_circle = square(2, type='circle') # Expected output: 12.56\r\n\r\n\"\"\"Invalid usage example\r\narea_invalid = square(3, type='invalid_shape') \r\nThis will raise ValueError\"\"\"\r\n\r\n- - ## distance-calculation\r\n- - - **Function: distance**\r\nCalculates various types of distances based on the specified type and dimension.\r\n\r\n**Parameters**\r\n```*args (float):``` Coordinates or parameters required for distance calculation.\r\n```type (str):``` The type of distance to calculate. Supported types include:\r\n'dist_points'\r\n'dist_point_line'\r\n'dist_point_plane'\r\n'dist_par_lines'\r\n'dist_par_planes'\r\n'dist_vectors'\r\n'dist_manhattan'\r\n'dist_cos'\r\n'dist_Chebyshev'\r\ndimension (str): The dimension of the space in which to calculate the distance. Acceptable values are:\r\n'2d'\r\n'3d'\r\n'euclid'\r\nReturns\r\nfloat: The calculated distance based on the specified type and dimension.\r\nRaises\r\nTypeError: If any of the arguments are not numeric, or if type or dimension are not strings.\r\nValueError: If the type or dimension is invalid.\r\n\r\n**Example of usage**\r\n\r\n\"\"\"Calculate distance between two points in 2D\"\"\"\r\ndist = distance(0, 0, 3, 4, type='dist_points', dimension='2d') # Output: 5.0\r\n\r\n\"\"\"Calculate Manhattan distance in 3D\"\"\"\r\nmanhattan_dist = distance(1, 2, 3, 4, 5, 6, type='dist_manhattan', dimension='3d') # Output: 9.0\r\n\r\n**Function: circumference**\r\nCalculates the circumference of a circle.\r\n\r\nParameters\r\n```r (float):``` The radius of the circle.\r\nReturns\r\nfloat: The calculated circumference of the circle.\r\nRaises\r\nTypeError: If the radius is not a number.\r\n\r\n**Example of usage**\r\n\r\n\"\"\"Calculate the circumference of a circle with radius 5\"\"\"\r\ncirc = circumference(5) # Output: 31.400000000000002\r\n\r\n\r\nHere's an explanation for the distance, circumference, arc_length, and vector_length functions from your FastMath library. This documentation will help users understand the purpose, parameters, return values, and potential exceptions raised by each function.\r\n\r\nFunction: distance\r\nCalculates various types of distances based on the specified type and dimension.\r\n\r\nParameters\r\n*args (float): Coordinates or parameters required for distance calculation.\r\ntype (str): The type of distance to calculate. Supported types include:\r\n'dist_points'\r\n'dist_point_line'\r\n'dist_point_plane'\r\n'dist_par_lines'\r\n'dist_par_planes'\r\n'dist_vectors'\r\n'dist_manhattan'\r\n'dist_cos'\r\n'dist_Chebyshev'\r\ndimension (str): The dimension of the space in which to calculate the distance. Acceptable values are:\r\n'2d'\r\n'3d'\r\n'euclid'\r\nReturns\r\nfloat: The calculated distance based on the specified type and dimension.\r\nRaises\r\nTypeError: If any of the arguments are not numeric, or if type or dimension are not strings.\r\nValueError: If the type or dimension is invalid.\r\nExample Usage\r\npython\r\n\u041a\u043e\u043f\u0456\u044e\u0432\u0430\u0442\u0438 \u043a\u043e\u0434\r\n# Calculate distance between two points in 2D\r\ndist = distance(0, 0, 3, 4, type='dist_points', dimension='2d') # Output: 5.0\r\n\r\n# Calculate Manhattan distance in 3D\r\nmanhattan_dist = distance(1, 2, 3, 4, 5, 6, type='dist_manhattan', dimension='3d') # Output: 9.0\r\nFunction: circumference\r\nCalculates the circumference of a circle.\r\n\r\nParameters\r\nr (float): The radius of the circle.\r\nReturns\r\nfloat: The calculated circumference of the circle.\r\nRaises\r\nTypeError: If the radius is not a number.\r\nExample Usage\r\npython\r\n\u041a\u043e\u043f\u0456\u044e\u0432\u0430\u0442\u0438 \u043a\u043e\u0434\r\n# Calculate the circumference of a circle with radius 5\r\ncirc = circumference(5) # Output: 31.400000000000002\r\n\r\n**Function: arc_length**\r\nCalculates the length of an arc of a circle.\r\n\r\nParameters\r\n```r (float):``` The radius of the circle.\r\n```rad (float):``` The angle in radians.\r\nReturns\r\nfloat: The calculated arc length.\r\nRaises\r\nTypeError: If either r or rad is not a number.\r\nValueError: If the angle is out of the valid range.\r\n\r\n**Example of usage**\r\n\r\n\"\"\"Calculate the length of an arc with radius 10 and angle \u03c0/2\"\"\"\r\narc = arc_length(10, 1.5708) # Output: 15.707999999999998\r\n\r\n**Function: vector_length**\r\nCalculates the length of a vector.\r\n\r\nParameters\r\n```*args (float):``` The components of the vector.\r\n```dimension (str):``` The dimension of the vector, either '2d' or '3d'.\r\nReturns\r\nfloat: The calculated length of the vector.\r\nRaises\r\nTypeError: If any arguments are not valid numbers or if dimension is not a string.\r\nValueError: If dimension is invalid.\r\n\r\n**Example of usage**\r\n\r\n\"\"\"Calculate the length of a 2D vector (3, 4)\"\"\"\r\nvec_length_2d = vector_length(3, 4, dimension='2d') # Output: 5.0\r\n\r\n\"\"\"Calculate the length of a 3D vector (1, 2, 2)\"\"\"\r\nvec_length_3d = vector_length(1, 2, 2, dimension='3d') # Output: 3.0\r\n\r\n- - ## mathematical-function\r\n- - - Docs for that module will be soon.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Toolkit for math calculations.",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/Matvei-Antipov/mathhunt-0.1.0.git",
"Source Code": "https://github.com/Matvei-Antipov/mathhunt"
},
"split_keywords": [
"math",
" calculations"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ea5a27894627ee8bd10928a6cca45fdda008b7b02c7c0f90f2eefb3e8ccb58d",
"md5": "1f56845bf8127a04d869f03fc2478533",
"sha256": "6d045f50c47b26e1325a2669db82d42401031591ae87e4c3258aca82c3ab2af3"
},
"downloads": -1,
"filename": "mathhunt-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1f56845bf8127a04d869f03fc2478533",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 51435,
"upload_time": "2024-10-17T06:12:14",
"upload_time_iso_8601": "2024-10-17T06:12:14.293887Z",
"url": "https://files.pythonhosted.org/packages/4e/a5/a27894627ee8bd10928a6cca45fdda008b7b02c7c0f90f2eefb3e8ccb58d/mathhunt-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9ff1c1f1d9c5ad45a9cc9164b088a47e8831a007568092f60f0a4597dbd2f402",
"md5": "c71d50bdea3c48406a4169f89525918a",
"sha256": "e31fee0008a75a492d41c264965d089d54a97075112af843e9a313a421956003"
},
"downloads": -1,
"filename": "mathhunt-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "c71d50bdea3c48406a4169f89525918a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 51320,
"upload_time": "2024-10-17T06:12:15",
"upload_time_iso_8601": "2024-10-17T06:12:15.979478Z",
"url": "https://files.pythonhosted.org/packages/9f/f1/c1f1d9c5ad45a9cc9164b088a47e8831a007568092f60f0a4597dbd2f402/mathhunt-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-17 06:12:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Matvei-Antipov",
"github_project": "mathhunt-0.1.0",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mathhunt"
}