diff --git a/src/facet.jl b/src/facet.jl index 1bd4995c..406cb18f 100644 --- a/src/facet.jl +++ b/src/facet.jl @@ -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 ################################################################ @@ -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 @@ -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) """ diff --git a/src/roughness.jl b/src/roughness.jl index 003e98c2..d022b7d8 100644 --- a/src/roughness.jl +++ b/src/roughness.jl @@ -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 @@ -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) d² = (x - xc)^2 + (y - yc)^2 d = √d² # Distance from the crater center @@ -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]