ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/vwright.c
Revision: 2.2
Committed: Thu Sep 14 21:36:32 1995 UTC (28 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +9 -15 lines
Log Message:
slight efficiency improvement and better error checking

File Contents

# Content
1 /* Copyright (c) 1995 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Move a viewpoint the given distance to the right
9 */
10
11
12 #include "standard.h"
13
14 #include "view.h"
15
16 VIEW vw = STDVIEW;
17
18 char *progname;
19
20
21 main(argc, argv)
22 int argc;
23 char *argv[];
24 {
25 char linebuf[256];
26 char *err;
27 int gotview = 0;
28 double dist;
29 register int i;
30
31 progname = argv[0];
32 if (argc != 2 || !isflt(argv[1])) {
33 fprintf(stderr, "Usage: %s offset\n", progname);
34 exit(1);
35 }
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 dist = atof(argv[1])/sqrt(vw.hn2);
51 for (i = 0; i < 3; i++)
52 vw.vp[i] += dist*vw.hvec[i];
53 fputs(VIEWSTR, stdout);
54 fprintview(&vw, stdout);
55 putchar('\n');
56 exit(0);
57 }