ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/vwright.c
Revision: 2.7
Committed: Tue Mar 11 02:21:47 2008 UTC (16 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R9
Changes since 2.6: +2 -1 lines
Log Message:
Added planisphere view type (-vts option) as requested by Axel Jacobs

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: vwright.c,v 2.6 2005/01/18 00:33:16 greg Exp $";
3 #endif
4 /*
5 * Move a viewpoint the given distance to the right
6 */
7
8
9 #include "standard.h"
10
11 #include "view.h"
12
13 #include <ctype.h>
14
15 VIEW vw = STDVIEW;
16
17 char *progname;
18
19
20 int
21 main(
22 int argc,
23 char *argv[]
24 )
25 {
26 char linebuf[256];
27 char *err;
28 int gotview = 0;
29 FVECT hvn, vvn;
30 double dist;
31 register int i;
32
33 progname = argv[0];
34 if (argc != 2)
35 goto userr;
36 while (fgets(linebuf, sizeof(linebuf), stdin) != NULL) {
37 if (linebuf[0] == '\n')
38 break;
39 if (isview(linebuf) && sscanview(&vw, linebuf) > 0)
40 gotview++;
41 }
42 if (!gotview) {
43 fprintf(stderr, "%s: no view on standard input\n", progname);
44 exit(1);
45 }
46 if ((err= setview(&vw)) != NULL) {
47 fprintf(stderr, "%s: %s\n", progname, err);
48 exit(1);
49 }
50 VCOPY(hvn, vw.hvec);
51 normalize(hvn);
52 VCOPY(vvn, vw.vvec);
53 normalize(vvn);
54 if (isalpha(argv[1][0])) { /* print out variables */
55 switch (vw.type) {
56 case VT_PER: i=1; break;
57 case VT_PAR: i=2; break;
58 case VT_ANG: i=3; break;
59 case VT_HEM: i=4; break;
60 case VT_CYL: i=5; break;
61 case VT_PLS: i=6; break;
62 default: i=0; break;
63 }
64 printf("%st:%d;", argv[1], i);
65 printf("%spx:%g;%spy:%g;%spz:%g;", argv[1], vw.vp[0],
66 argv[1], vw.vp[1], argv[1], vw.vp[2]);
67 printf("%sdx:%g;%sdy:%g;%sdz:%g;", argv[1], vw.vdir[0],
68 argv[1], vw.vdir[1], argv[1], vw.vdir[2]);
69 printf("%sd:%g;", argv[1], vw.vdist);
70 printf("%sux:%g;%suy:%g;%suz:%g;", argv[1], vw.vup[0],
71 argv[1], vw.vup[1], argv[1], vw.vup[2]);
72 printf("%sh:%g;%sv:%g;", argv[1], vw.horiz,
73 argv[1], vw.vert);
74 printf("%ss:%g;%sl:%g;%so:%g;%sa:%g;",
75 argv[1], vw.hoff, argv[1], vw.voff,
76 argv[1], vw.vfore, argv[1], vw.vaft);
77 printf("%shx:%g;%shy:%g;%shz:%g;%shn:%g;",
78 argv[1], hvn[0], argv[1], hvn[1],
79 argv[1], hvn[2], argv[1], sqrt(vw.hn2));
80 printf("%svx:%g;%svy:%g;%svz:%g;%svn:%g;\n",
81 argv[1], vvn[0], argv[1], vvn[1],
82 argv[1], vvn[2], argv[1], sqrt(vw.vn2));
83 exit(0);
84 }
85 if (!isflt(argv[1]))
86 goto userr;
87 dist = atof(argv[1]);
88 for (i = 0; i < 3; i++)
89 vw.vp[i] += dist*hvn[i];
90 fprintview(&vw, stdout);
91 putchar('\n');
92 exit(0);
93 userr:
94 fprintf(stderr, "Usage: %s {offset|name}\n", progname);
95 exit(1);
96 }