FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

New view angle parameter "azimuth" allows rotation of a 3D plot about… · gnuplot/gnuplot-old@f6aa666 · GitHub

Repository navigation

Commit f6aa666

Browse files
sfeam
committed
New view angle parameter "azimuth" allows rotation of a 3D plot about the line of sight through the origin.
1 parent bdf5412 commit f6aa666

14 files changed

Lines changed: 106 additions & 17 deletions

File tree

‎ChangeLog‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2016-09-10 Ethan A Merritt <merritt@u.washington.edu>
2+
3+
* src/graph3d.c src/graph3d.h src/mouse.c src/save.c src/set.c
4+
src/show.c src/unset.c src/eval.c docs/gnuplot.doc demo/azimuth.dem:
5+
6+
New command "set view azimuth <angle-in-degrees>"
7+
Changing the view angles rot_x and rot_z cannot move the z axis out of
8+
the plane normal to the canvas horizontal. This patch adds a new angular
9+
setting "azimuth" that rotates the plane containing the z axis about
10+
the line of sight. I.e. "set view azimuth 90" places the z axis
11+
parallel to the canvas horizontal rather than the canvas vertical.
12+
Click-and-drag with right mouse button provides interactive control of
13+
the azimuth. Azimuth is ignored by 2D plots and by "set view map".
14+
115
2016-09-09 Shigeharu Takeno <shige@iee.niit.ac.jp>
216

317
* docs/term-ja.diff docs/gnuplot-ja.doc:

‎NEWS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Changes not in 5.0
2222
* NEW command "set minussign" (first appeared in 5.0.5)
2323
* NEW "smooth fnormal" normalized frequency
2424
* NEW terminal domterm (supports in-line SVG in DomTerm terminal emulator)
25+
* NEW "set view azimuth <angle>" controls azimuth of the z axis in 3D plots
2526
* CHANGE Revise placement of axis labels in 3D plots
2627
* CHANGE Track font/enhanced for key title separately from the key entries
2728
* CHANGE order of margins in `set margins <left>, <right>, <bottom>, <top>`

‎demo/all.dem‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: all.dem,v 1.74 2016-08-04 03:42:27 sfeam Exp $
2+
# $Id: all.dem,v 1.75 2016-09-10 05:46:21 sfeam Exp $
33
#
44
# Executes all demos (OK, MOST demos) in this directory.
55
# This serves as a series of unit tests for non-interactive capabilities.
@@ -159,6 +159,10 @@ print "******************** file surface2.dem ********************"
159159
load "surface2.dem"
160160
reset
161161

162+
print "******************** file azimuth.dem ********************"
163+
load "azimuth.dem"
164+
reset
165+
162166
print "******************** file contours.dem ********************"
163167
load "contours.dem"
164168
reset

‎demo/azimuth.dem‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set view equal xy
2+
set zzeroaxis; set xzeroaxis; set yzeroaxis
3+
set xyplane at 0
4+
unset border
5+
unset key
6+
unset xtics
7+
unset ytics
8+
set ztics axis
9+
10+
set arrow 1 from 0,0,0 to 1,0,0 head filled lw 1.5
11+
set label 1 at 1.2,0,0 "X" center
12+
set arrow 2 from 0,0,0 to 0,1,0 head filled lw 1.5
13+
set label 2 at 0,1.2,0 "Y" center
14+
set arrow 3 from 0,0,0 to 0,0,21 head filled lw 1.5
15+
set label 3 at 0,0,23 "Z" center
16+
17+
set view 60, 30, 1., 1.75
18+
19+
set multiplot layout 1,3
20+
21+
set view azimuth 0.
22+
set title 'azimuth 0' offset 0,2
23+
splot sample [t=0:20] '+' using (cos($1)):(sin($1)):($1) with lines lw 2
24+
25+
set title 'azimuth 10' offset 0,2
26+
set view azimuth 10.
27+
replot
28+
29+
set title 'azimuth 60' offset 0,2
30+
set view azimuth 60.
31+
replot
32+
33+
unset multiplot
34+
pause -1 "Hit return to continue"
35+
reset

‎demo/world.dem‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: world.dem,v 1.11 2014/10/05 00:33:15 sfeam Exp $
2+
# $Id: world.dem,v 1.12 2016-09-10 05:46:22 sfeam Exp $
33
#
44
#
55
set title "Gnuplot Correspondences\ngeographic coordinate system"
@@ -27,6 +27,7 @@ set angles degrees
2727
set title "3D version using spherical coordinate system"
2828
set ticslevel 0
2929
set view 70,40,0.8,1.2
30+
set view equal xyz
3031
set mapping spherical
3132
set parametric
3233
set samples 32
@@ -56,6 +57,7 @@ unset arrow
5657
set title "3D version using cylindrical coordinate system"
5758
set ticslevel 0.0
5859
set view 70,40,0.8,1.2
60+
set view equal xy
5961
set mapping cylindrical
6062
set parametric
6163
set samples 32

‎docs/gnuplot.doc‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
C RCS $Id: gnuplot.doc,v 1.1018 2016-09-08 20:17:04 sfeam Exp $
1+
C RCS $Id: gnuplot.doc,v 1.1019 2016-09-10 05:46:22 sfeam Exp $
22
C
33
C Copyright (C) 1986 - 1993, 1998, 1999, 2000, 2001, 2004 Thomas Williams, Colin Kelley et al.
44
C
@@ -204,6 +204,8 @@ C
204204

205205
* New commands `break` and `continue` allow more complicated loop structure.
206206

207+
* 3D plots can be rotated about the line of sight (see `set view azimuth`).
208+
207209
* Support for array variables (see `arrays`).
208210

209211
* Support for nonlinear axes (see `set nonlinear`).
@@ -13142,6 +13144,7 @@ Ffigure_multiple_keys
1314213144
set view <rot_x>{,{<rot_z>}{,{<scale>}{,<scale_z>}}}
1314313145
set view map {scale <scale>}
1314413146
set view {no}equal {xy|xyz}
13147+
set view azimuth <angle>
1314513148
show view
1314613149

1314713150
where <rot_x> and <rot_z> control the rotation angles (in degrees) in a
@@ -13167,6 +13170,17 @@ Ffigure_multiple_keys
1316713170

1316813171
The first sets all the four default values. The second changes only scale,
1316913172
to 0.5.
13173+
4 azimuth
13174+
?set view azimuth
13175+
?view azimuth
13176+
?azimuth
13177+
set view azimuth <angle-in-degrees>
13178+
The setting of azimuth affects the orientation of the z axis in a 3D graph
13179+
(splot). At the default azimuth = 0 the z axis of the plot lies in the plane
13180+
orthogonal to the screen horizontal. I.e. the projection of the z axis lies
13181+
along the screen vertical. Non-zero azimuth rotates the plot about the line
13182+
of sight through the origin so that a projection of the z axis is no longer
13183+
vertical. When azimuth = 90 the z axis is horizontal rather than vertical.
1317013184
4 equal_axes
1317113185
?set view equal_axes
1317213186
?set view equal xyz

‎src/eval.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: eval.c,v 1.139 2016-09-08 15:21:02 markisch Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: eval.c,v 1.140 2016-09-10 05:46:22 sfeam Exp $"); }
33
#endif
44

55
/* GNUPLOT - eval.c */
@@ -972,6 +972,7 @@ update_gpval_variables(int context)
972972
fill_gpval_float("GPVAL_VIEW_ROT_Z", surface_rot_z);
973973
fill_gpval_float("GPVAL_VIEW_SCALE", surface_scale);
974974
fill_gpval_float("GPVAL_VIEW_ZSCALE", surface_zscale);
975+
fill_gpval_float("GPVAL_VIEW_AZIMUTH", azimuth);
975976
return;
976977
}
977978

‎src/graph3d.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.345 2016-09-06 22:53:17 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.346 2016-09-10 05:46:22 sfeam Exp $"); }
33
#endif
44

55
/* GNUPLOT - graph3d.c */
@@ -95,6 +95,7 @@ float surface_scale = 1.0;
9595
float surface_zscale = 1.0;
9696
float surface_lscale = 0.0;
9797
float mapview_scale = 1.0;
98+
float azimuth = 0.0;
9899

99100
/* Set by 'set view map': */
100101
int splot_map = FALSE;
@@ -638,10 +639,11 @@ do_3dplot(
638639
mat_scale(surface_scale / 2.0, surface_scale / 2.0, surface_scale / 2.0, mat);
639640
mat_mult(trans_mat, trans_mat, mat);
640641

641-
/* The extrema need to be set even when a surface is not being
642-
* drawn. Without this, gnuplot used to assume that the X and
643-
* Y axis started at zero. -RKC
644-
*/
642+
/* The azimuth is applied as a rotation about the line of sight */
643+
if (azimuth !=0 && !splot_map) {
644+
mat_rot_z(azimuth, mat);
645+
mat_mult(trans_mat, trans_mat, mat);
646+
}
645647

646648
if (polar)
647649
int_error(NO_CARET,"Cannot splot in polar coordinate system.");
@@ -806,7 +808,7 @@ do_3dplot(
806808
* difference for other terminals. If it causes problems, then we will need
807809
* a separate BoundingBox structure to track the actual 3D graph box.
808810
*/
809-
else {
811+
else if (azimuth == 0) {
810812
int xl, xb, xr, xf, yl, yb, yr, yf;
811813

812814
map3d_xy(zaxis_x, zaxis_y, base_z, &xl, &yl);

‎src/graph3d.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: graph3d.h,v 1.51 2016-05-09 03:32:27 sfeam Exp $
2+
* $Id: graph3d.h,v 1.52 2016-09-10 05:46:22 sfeam Exp $
33
*/
44

55
/* GNUPLOT - graph3d.h */
@@ -151,6 +151,7 @@ extern float surface_scale;
151151
extern float surface_zscale;
152152
extern float surface_lscale;
153153
extern float mapview_scale;
154+
extern float azimuth;
154155
extern int splot_map;
155156

156157
typedef struct {

‎src/mouse.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: mouse.c,v 1.190 2016-08-06 05:47:08 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: mouse.c,v 1.191 2016-09-10 05:46:22 sfeam Exp $"); }
33
#endif
44

55
/* GNUPLOT - mouse.c */
@@ -2119,7 +2119,12 @@ event_motion(struct gp_event_t *ge)
21192119
start_x = mouse_x;
21202120
start_y = mouse_y;
21212121
redraw = TRUE;
2122-
} /* if (mousebutton 2 is down) */
2122+
} else if (button & (1 << 3)) {
2123+
/* dragging with button 3 -> change azimuth */
2124+
azimuth += (mouse_x - start_x) * 90.0 / term->xmax;
2125+
start_x = mouse_x;
2126+
redraw = TRUE;
2127+
}
21232128

21242129
if (!ALMOST2D) {
21252130
turn_ruler_off();
@@ -2136,6 +2141,7 @@ event_motion(struct gp_event_t *ge)
21362141
fill_gpval_float("GPVAL_VIEW_ROT_Z", surface_rot_z);
21372142
fill_gpval_float("GPVAL_VIEW_SCALE", surface_scale);
21382143
fill_gpval_float("GPVAL_VIEW_ZSCALE", surface_zscale);
2144+
fill_gpval_float("GPVAL_VIEW_AZIMUTH", azimuth);
21392145
} else {
21402146
/* postpone the replotting */
21412147
needreplot = TRUE;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL