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

# User Rev Content
1 greg 2.2 /* Copyright (c) 1995 Regents of the University of California */
2 greg 2.1
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 greg 2.2 VIEW vw = STDVIEW;
17 greg 2.1
18     char *progname;
19    
20    
21     main(argc, argv)
22     int argc;
23     char *argv[];
24     {
25     char linebuf[256];
26 greg 2.2 char *err;
27 greg 2.1 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 greg 2.2 if (isview(linebuf) && sscanview(&vw, linebuf) > 0)
40 greg 2.1 gotview++;
41     }
42     if (!gotview) {
43     fprintf(stderr, "%s: no view on standard input\n", progname);
44     exit(1);
45     }
46 greg 2.2 if ((err= setview(&vw)) != NULL) {
47     fprintf(stderr, "%s: %s\n", progname, err);
48 greg 2.1 exit(1);
49     }
50 greg 2.2 dist = atof(argv[1])/sqrt(vw.hn2);
51 greg 2.1 for (i = 0; i < 3; i++)
52 greg 2.2 vw.vp[i] += dist*vw.hvec[i];
53 greg 2.1 fputs(VIEWSTR, stdout);
54 greg 2.2 fprintview(&vw, stdout);
55 greg 2.1 putchar('\n');
56     exit(0);
57     }