Skip to content
Snippets Groups Projects
Commit d9fd62ab authored by Dieter Weber's avatar Dieter Weber
Browse files

Handle negative z values correctly

parent 914d7c13
No related branches found
No related tags found
1 merge request!2Fix clipping of rgb_from_vector()
Pipeline #51686 failed
......@@ -78,7 +78,7 @@ class Colormap3D(colors.Colormap, metaclass=abc.ABCMeta):
r, g, b = interpolate_color(sat, (0.5, 0.5, 0.5), np.stack((r, g, b), axis=-1))
# THIRD color dimension: LUMINANCE (3D, color sphere)
z_max = vmax if vmax is not None else np.abs(z).max() + 1E-30
z_clipped = np.minimum(np.abs(z), z_max) / z_max
z_clipped = np.minimum(np.abs(z), z_max) / z_max * np.sign(z)
theta = np.arccos(z_clipped)
lum = 1 - theta / np.pi # goes from 0 (black) over 0.5 (grey) to 1 (white)!
lum_target = np.where(lum < 0.5, 0, 1) # Separate upper(white)/lower(black) hemispheres!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment