Skip to content

Commit

Permalink
add more argument types (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium authored Nov 19, 2023
1 parent 0d33f28 commit ae414e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/facet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# # Face properties
# ################################################################

face_center(vs) = face_center(vs...)
face_center(v1, v2, v3) = (v1 + v2 + v3) / 3
face_center(vs::StaticVector{3, <:StaticVector{3}}) = face_center(vs...)
face_center(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) = (v1 + v2 + v3) / 3

face_normal(vs) = face_normal(vs...)
face_normal(v1, v2, v3) = normalize((v2 - v1) × (v3 - v2))
face_normal(vs::StaticVector{3, <:StaticVector{3}}) = face_normal(vs...)
face_normal(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) = normalize((v2 - v1) × (v3 - v2))

face_area(vs) = face_area(vs...)
face_area(v1, v2, v3) = norm((v2 - v1) × (v3 - v2)) / 2
face_area(vs::StaticVector{3, <:StaticVector{3}}) = face_area(vs...)
face_area(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) = norm((v2 - v1) × (v3 - v2)) / 2


################################################################
Expand Down Expand Up @@ -54,7 +54,7 @@ end
Intersection detection between ray R and triangle ABC.
Note that the starting point of the ray is the origin (0, 0, 0).
"""
function raycast(A, B, C, R)
function raycast(A::StaticVector{3}, B::StaticVector{3}, C::StaticVector{3}, R::StaticVector{3})
E1 = B - A
E2 = C - A
T = - A
Expand All @@ -77,7 +77,7 @@ end
Intersection detection between ray R and triangle ABC.
Use when the starting point of the ray is an arbitrary point `O`.
"""
raycast(A, B, C, R, O) = raycast(A - O, B - O, C - O, R)
raycast(A::StaticVector{3}, B::StaticVector{3}, C::StaticVector{3}, R::StaticVector{3}, O::StaticVector{3}) = raycast(A - O, B - O, C - O, R)


"""
Expand Down
6 changes: 3 additions & 3 deletions src/roughness.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Return the curvature radius of a concave spherical segment.
- `r`: Crater radius
- `h`: Crater depth
"""
crater_curvature_radius(r, h) = (r^2 + h^2) / 2h
crater_curvature_radius(r::Real, h::Real) = (r^2 + h^2) / 2h

"""
concave_spherical_segment(r, h, xc, yc, x, y) -> z
Expand All @@ -28,7 +28,7 @@ Return the z-coordinate of a concave spherical segment.
- `x` : x-coordinate where to calculate z
- `y` : y-coordinate where to calculate z
"""
function concave_spherical_segment(r, h, xc, yc, x, y)
function concave_spherical_segment(r::Real, h::Real, xc::Real, yc::Real, x::Real, y::Real)
= (x - xc)^2 + (y - yc)^2
d = # Distance from the crater center

Expand All @@ -54,7 +54,7 @@ Return (x, y, z) grid of a concave spherical segment.
- `xc`: x-coordinate of crater center
- `yc`: y-coordinate of crater center
"""
function concave_spherical_segment(r, h; Nx=2^5, Ny=2^5, xc=0.5, yc=0.5)
function concave_spherical_segment(r::Real, h::Real; Nx::Integer=2^5, Ny::Integer=2^5, xc::Real=0.5, yc::Real=0.5)
xs = LinRange(0, 1, Nx + 1)
ys = LinRange(0, 1, Ny + 1)
zs = [concave_spherical_segment(r, h, xc, yc, x, y) for x in xs, y in ys]
Expand Down

0 comments on commit ae414e8

Please sign in to comment.