Area Crate v1.0.2
A comprehensive Rust library for geometric calculations, providing functions for calculating areas, perimeters, surface areas, and volumes of various shapes.
Features
- 2D shape area calculations (circle, triangle, square, rectangle, trapezoid, parallelogram, ellipse, etc.)
- 3D shape surface area calculations (cube, sphere, cylinder, cone)
- 3D shape volume calculations
- Perimeter calculations for 2D shapes
- Error handling for invalid inputs
- High-precision mathematical constants
- Well-documented API
- Zero dependencies
Installation
Add this to your Cargo.toml:
[]
= "1.0.2"
Usage Examples
Area Calculations
use ;
Surface Area and Volume Calculations
use ;
Using Constants
use ;
Available Functions
Areas (2D)
- Circle
- Triangle
- Square
- Rectangle
- Trapezoid
- Parallelogram
- Ellipse
- Sector
- Rhombus
- Kite
- Regular polygon
- Annulus
- Pentagon
- Hexagon
- N-sided polygon
- Circular segment
Perimeters
- Circle
- Rectangle
- Triangle
- Regular polygon
Surface Areas (3D)
- Cube
- Sphere
- Cylinder
- Cone
Volumes (3D)
- Cube
- Sphere
- Cylinder
- Cone
- Rectangular prism
Error Handling
All functions now return a Result type, properly handling invalid inputs:
use area;
License
This project is licensed under the MIT License. See the LICENSE file for details