Skip to content

Commit cdf8b57

Browse files
committed
Move distance_squared to submodule ConstructiveSolidGeometry
1 parent f75025e commit cdf8b57

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/ChargeClustering/ChargeClustering.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ function cluster_detector_hits(table::TypedTables.Table, cluster_radius::RealQua
7474
end
7575

7676

77-
distance_squared(p1::CartesianPoint{T}, p2::CartesianPoint{T}) where {T <: SSDFloat} = (p1.x - p2.x)^2 + (p1.y - p2.y)^2 + (p1.z - p2.z)^2
78-
7977
function _group_points_by_distance(pts::AbstractVector{CartesianPoint{T}}, group_distance::T)::Tuple{Vector{Int}, Vector{Int}} where {T}
8078

8179
n::Int = length(pts)

src/ChargeDrift/ChargeDrift.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function _add_fieldvector_selfrepulsion!(step_vectors::Vector{CartesianVector{T}
130130
if iszero(direction) # if the two charges are at the exact same position
131131
continue # don't let them self-repel each other but treat them as same change
132132
end # if diffusion is simulated, they will very likely be separated in the next step
133-
tmp::T = elementary_charge * inv(4 * pi * ϵ0 * ϵ_r * max(sum(direction.^2), T(1e-10))) # minimum distance is 10µm
133+
tmp::T = elementary_charge * inv(4π * ϵ0 * ϵ_r * max(distance_squared(direction), T(1e-10))) # minimum distance is 10µm
134134
step_vectors[n] += charges[m] * tmp * normalize(direction)
135135
step_vectors[m] -= charges[n] * tmp * normalize(direction)
136136
end

src/ConstructiveSolidGeometry/PointsAndVectors/PointsAndVectors.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ abstract type AbstractCoordinateVector{T, S} <: StaticArrays.FieldVector{3, T} e
33

44
include("Points.jl")
55
include("Vectors.jl")
6+
7+
@inline distance_squared(v::CartesianVector) = v.x * v.x + v.y * v.y + v.z * v.z
8+
@inline distance_squared(p1::CartesianPoint{T}, p2::CartesianPoint{T}) where {T <: Real} = distance_squared(CartesianVector(p1 .- p2))
9+
export distance_squared

0 commit comments

Comments
 (0)