Skip to content

Commit 9d39d79

Browse files
committed
Ball Volume and Surface.
1 parent e161d94 commit 9d39d79

2 files changed

Lines changed: 51 additions & 3 deletions

File tree

Project.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
name = "N_Balls"
2-
uuid = "1516a9df-afe8-4e6d-b045-52d61e3c975e"
3-
authors = ["Vectorized_Mind"]
2+
uuid = "931db479-4bb7-4c79-b0ca-9b52654c2507"
43
version = "1.0.0-DEV"
4+
authors = ["Vectorized_Mind"]
5+
6+
[deps]
7+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
8+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
59

610
[compat]
11+
DataFrames = "1.8.1"
12+
SpecialFunctions = "2.7.1"
713
julia = "1.10.10"
814

915
[extras]
16+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
17+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1018
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1119

1220
[targets]

src/N_Balls.jl

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
module N_Balls
22

3-
# Write your package code here.
3+
import SpecialFunctions:gamma
4+
import DataFrames:DataFrame
5+
export n_ball_surface
6+
export n_ball_volume
7+
export n_ball_vol_surf
48

9+
@inline function n_ball_volume(r::Float64,n::Int64)
10+
y=(pi^(n/2))*r^n/gamma((n/2)+1)
11+
return y
12+
end
13+
14+
@inline function n_ball_surface(r::Float64,n::Int64)
15+
y=(2*pi^(n/2))*r^(n-1)/gamma(n/2)
16+
return y
17+
end
18+
19+
@inline function n_ball_vol_surf(r::Float64,n::Int64)
20+
s="$(n_ball_volume(r,n))"
21+
s1="$n-Ball Volume: "
22+
s2="$(n_ball_surface(r,n))"
23+
s3="$n-Ball Surface/Area: "
24+
println(s1*s)
25+
println(s3*s2)
526
end
27+
28+
@inline function n_ball_volume(r::Vector{Float64},n::Int64)
29+
(pi^(n/2).*r.^(n))./gamma(n/(2)+1)
30+
end
31+
32+
@inline function n_ball_surface(r::Vector{Float64},n::Int64)
33+
(2*pi^(n/2).*r.^(n-1))./gamma(n/(2))
34+
end
35+
36+
@inline function n_ball_vol_surf(r::Vector{Float64},n::Int64)
37+
x=n_ball_surface(r,n)
38+
y=n_ball_volume(r,n)
39+
s="$n-Ball Volume"
40+
s1="$n-Ball Surface"
41+
return(DataFrame(s1=>x,s=>y))
42+
end
43+
44+
45+
end

0 commit comments

Comments
 (0)