Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akshitvadodariya1201/area_crate
Basic Area Crate
https://github.com/akshitvadodariya1201/area_crate
cargo crate crates-io rust rust-library
Last synced: about 1 month ago
JSON representation
Basic Area Crate
- Host: GitHub
- URL: https://github.com/akshitvadodariya1201/area_crate
- Owner: AkshitVadodariya1201
- Created: 2024-06-15T12:34:12.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-06-15T12:39:30.000Z (6 months ago)
- Last Synced: 2024-06-15T13:58:45.726Z (6 months ago)
- Topics: cargo, crate, crates-io, rust, rust-library
- Language: Rust
- Homepage: https://crates.io/crates/area_crate
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic Area Crate
This is a collection of some generally used area functions.
## Find the Area
### Example
#### Area of Circle
```rust
let radius = 12.0;
let answer = area_crate::area::circle(radius);
assert_eq!(452.38934211696005, answer);
```## Functions
### Circle Area
```rust
pub fn circle(radius: f64) -> f64 {
let pi = 3.14159265359;
pi * radius * radius
}
```### Triangle Area
```rust
pub fn triangle(base: f64, height: f64) -> f64 {
0.5 * base * height
}
```### Rectangle Area
```rust
pub fn rectangle(length: f64, breadth: f64) -> f64 {
length * breadth
}
```### Square Area
```rust
pub fn square(side: f64) -> f64 {
side * side
}
```### Parallelogram Area
```rust
pub fn parallelogram(base: f64, height: f64) -> f64 {
base * height
}
```### Trapezoid Area
```rust
pub fn trapezoid(base1: f64, base2: f64, height: f64) -> f64 {
0.5 * (base1 + base2) * height
}
```### Ellipse Area
```rust
pub fn ellipse(major_axis: f64, minor_axis: f64) -> f64 {
let pi = 3.14159265359;
pi * major_axis * minor_axis
}
```### Sector Area
```rust
pub fn sector(radius: f64, angle: f64) -> f64 {
let pi = 3.14159265359;
0.5 * radius * radius * angle.to_radians()
}
```### Rhombus Area
```rust
pub fn rhombus(diagonal1: f64, diagonal2: f64) -> f64 {
0.5 * diagonal1 * diagonal2
}
```### Kite Area
```rust
pub fn kite(diagonal1: f64, diagonal2: f64) -> f64 {
0.5 * diagonal1 * diagonal2
}
```### Regular Polygon Area
```rust
pub fn regular_polygon(perimeter: f64, apothem: f64) -> f64 {
0.5 * perimeter * apothem
}
```### Annulus Area
```rust
pub fn annulus(outer_radius: f64, inner_radius: f64) -> f64 {
let pi = 3.14159265359;
pi * (outer_radius * outer_radius - inner_radius * inner_radius)
}
```