Skip to content

Commit ee5f2db

Browse files
committed
Slight tweak to rescaling heuristics
Improves a bit the visualization in tutorial "SW19_Different_Ions"
1 parent 1f462cb commit ee5f2db

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ext/PlottingExt/ViewCrystal.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,15 @@ function scaled_dipole_to_arrow_geometry(dipole, lengthscale, tiplength)
326326
# In the typical case, spin magnitude will be denoted by shaft length.
327327
shaftlength0 = s * lengthscale
328328

329-
# If magnitude is too small, however, then it will be depicted as the
330-
# _volume_ of the arrow tip. This is achieved by effectively scaling
331-
# tiplength by a reduction factor c ~ cbrt(s) ≤ 1.
332-
r = shaftlength0 / tiplength
329+
# If spin magnitude is too small, reduce overall arrow length by the factor
330+
# c ~ cbrt(s) ≤ 1. Here, the spin magnitude is effectively represented by
331+
# the _volume_ of the arrow tip.
332+
r = shaftlength0 / (0.5 * tiplength)
333333
c = cbrt(min(r, 1))
334-
full_length = shaftlength0 + c * tiplength
334+
full_length = c * (shaftlength0 + tiplength)
335335

336-
# Calculate the true space remaining for the shaft. If tiplength exceeds
337-
# full_length, then Makie will automatically scale arrow arrow geometry to
338-
# honor full_length.
336+
# The true space remaining for the shaft. If no space is left, Makie will
337+
# also rescale the arrow tip as needed to achieve the requested full_length.
339338
shaftlength = max(full_length - tiplength, 0)
340339

341340
offset = -(shaftlength/2) * dir

0 commit comments

Comments
 (0)