Mercurial > octave
changeset 33458:1ad552012ffb
view.m: Improve behavior with view point on main axis (bug #65641).
* view.m: Rotate input to cart2sph by 90° instead of its output. Add more self
tests for view points on main axis.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 25 Apr 2024 16:24:25 +0200 |
parents | 9d0dfb038536 |
children | 4401310ad737 |
files | scripts/plot/appearance/view.m |
diffstat | 1 files changed, 22 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/view.m Thu Apr 25 10:47:40 2024 -0400 +++ b/scripts/plot/appearance/view.m Thu Apr 25 16:24:25 2024 +0200 @@ -74,11 +74,13 @@ az = x(1); el = x(2); elseif (numel (x) == 3) - [az, el] = cart2sph (x(1), x(2), x(3)); + if (x(2) == 0) + ## special case for negative 0 + [az, el] = cart2sph (x(2), x(1), x(3)); + else + [az, el] = cart2sph (-x(2), x(1), x(3)); + endif az *= 180/pi; - if (az != 0) - az += 90; # Special fix for bug #57800 - endif el *= 180/pi; elseif (x == 2) az = 0; @@ -141,7 +143,6 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); -%! view (3); %! view ([0, 0, 1]); %! [az, el] = view (); %! assert ([az, el], [0, 90], eps); @@ -149,22 +150,31 @@ %! close (hf); %! end_unwind_protect -%!test <65641> +%!test <*65641> %! hf = figure ("visible", "off"); %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); -%! view (3); +%! view ([1, 0, 0]); +%! [az, el] = view (); +%! assert ([az, el], [90, 0], eps); +%! view ([-1, 0, 0]); +%! [az, el] = view (); +%! assert ([az, el], [-90, 0], eps); +%! view ([0, 1, 0]); +%! [az, el] = view (); +%! assert ([az, el], [180, 0], eps); %! view ([0, -1, 0]); %! [az, el] = view (); %! assert ([az, el], [0, 0], eps); -%! view (3); -%! view ([1, 0, 0]); +%! view ([0, 0, 1]); %! [az, el] = view (); -%! assert ([az, el], [90, 0], eps); -%! view (3); +%! assert ([az, el], [0, 90], eps); +%! view ([0, 0, -1]); +%! [az, el] = view (); +%! assert ([az, el], [0, -90], eps); %! view ([1, 0.001, 0]); %! [az, el] = view (); -%! assert ([az, el], [90 + 0.001*180/pi, 0], eps); +%! assert ([az, el], [90 + 0.001*180/pi, 0], eps ("single")); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect