Skip to content

Commit

Permalink
remove leftover tuple conversions (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrof authored Oct 26, 2023
1 parent 4e65086 commit 14ce4dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/MicrobeAgents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ microbe type lives (1, 2 and 3 are supported).
All microbe types *must* have at least the following fields:
- `id::Int` id of the microbe (used internally by Agents.jl)
- `pos::NTuple{D,Float64}` position of the microbe
- `vel::NTuple{D,Float64}` velocity of the microbe
- `pos::SVectpr{D,Float64}` position of the microbe
- `vel::SVector{D,Float64}` velocity of the microbe
- `motility::AbstractMotility` motile pattern of the microbe
- `turn_rate::Real` average reorientation rate of the microbe
- `rotational_diffusivity::Real` coefficient of brownian rotational diffusion
Expand Down
6 changes: 2 additions & 4 deletions src/rotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function turn!(microbe::AbstractMicrobe, model)
# extract new speed and rotation angles
U₁, θ, ϕ = rand(abmrng(model), microbe.motility)
# reorient and update speed
microbe.vel = Tuple(rotate(v, θ, ϕ))
microbe.vel = rotate(v, θ, ϕ)
microbe.speed = U₁
# switch motile state (does nothing if motility is one-step)
switch!(microbe.motility)
Expand All @@ -21,12 +21,10 @@ function rotational_diffusion!(microbe::AbstractMicrobe, model)
σ = sqrt(2*D_rot*dt)
θ = rand(abmrng(model), Normal(0,σ))
ϕ = rand(abmrng(model), Arccos())
microbe.vel = Tuple(rotate(microbe.vel, θ, ϕ))
microbe.vel = rotate(microbe.vel, θ, ϕ)
nothing
end

rotate(w::Tuple, θ, ϕ) = rotate(SVector(w), θ, ϕ)

"""
rotate(w::SVector{D}, θ, ϕ) where D
Rotate `D`-dimensional vector `w` by angles `θ` and `ϕ`.
Expand Down

0 comments on commit 14ce4dd

Please sign in to comment.