ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/doc/man/man1/icalc.1
Revision: 1.4
Committed: Mon Jun 10 13:56:52 2019 UTC (5 years ago) by greg
Branch: MAIN
CVS Tags: rad5R3
Changes since 1.3: +7 -1 lines
Log Message:
Added max() and min() as .cal library functions

File Contents

# User Rev Content
1 greg 1.4 .\" RCSid "$Id: icalc.1,v 1.3 2013/12/19 16:38:12 greg Exp $"
2 greg 1.1 .TH ICALC 1 2/3/95 RADIANCE
3     .SH NAME
4     icalc - interactive calculator
5     .SH SYNOPSIS
6     .B icalc
7     [
8     .B file
9     ]
10     .SH DESCRIPTION
11     .I Icalc
12     is a algebraic calculator designed primarily for
13     interactive use.
14     Each formula definition
15     .I file
16 greg 1.3 is read and compiled from the RADIANCE library where it is found.
17 greg 1.1 The standard input is then read, expressions are evaluated
18     and results are sent to the standard output.
19     If a newline is escaped using a backslash, input is continued
20     on the next line.
21     .PP
22     An expression contains real numbers, variable names, function calls,
23     and the following operators:
24     .PP
25     + - * / ^
26     .PP
27     Operators are evaluated left to right, except '^',
28     which is right associative.
29     Exponentiation has the highest precedence; multiplication and
30     division are evaluated before addition and subtraction.
31     Expressions can be grouped with parentheses.
32     Each result is assigned a number, which can be used in future expressions.
33     For example, the expression ($3*10) is the result of the
34     third calculation multiplied by ten.
35     A dollar sign by itself may be used for the previous result.
36     All values are double precision real.
37     .PP
38     In addition, variables and functions can be defined by the
39     user.
40     A variable definition has the form:
41     .PP
42    
43     var = expression ;
44    
45     .PP
46     Any instance of the variable in an expression will be replaced
47     with its definition.
48     A function definition has the form:
49     .PP
50    
51     func(a1, a2, ..) = expression ;
52    
53     .PP
54     The expression can contain instances of the function arguments
55     as well as other variables and functions.
56     Function names can be passed as arguments.
57     Recursive functions can be defined using calls to the defined
58     function or other functions calling the defined function.
59     .PP
60     To define a constant expression, simply replace the equals sign ('=')
61     with a colon (':') in a definition.
62     Constant expressions are evaluated only once, the first time they are used.
63     This avoids repeated evaluation of expressions whose values never change.
64     Ideally, a constant expression contains only numbers and references
65     to previously defined constant expressions and functions.
66     Constant function definitions are are
67     replaced by their value in any expression that uses them with constant
68     arguments.
69     All predefined functions and variables have the constant attribute.
70     Thus, "sin(PI/4)" in an expression would be immediately replaced by ".707108"
71     unless sin() or PI were redefined by the user.
72     (Note that redefining constant expressions is not a recommended practice!)\
73     .PP
74     A variable or function's definition can be displayed with the '?'
75     command:
76     .PP
77     ? name
78     .PP
79     If no name is given, all definitions are printed.
80     The '>' command writes definitions to a file:
81     .PP
82     > file
83     .PP
84     Similarly, the '<' command loads definitions.
85     .PP
86     The following library of predefined functions and variables is provided:
87     .TP 10n
88     .BR PI
89     the ratio of a circle's circumference to its diameter.
90     .TP
91     .BR "if(cond, then, else)"
92     if cond is greater than zero,
93     then is evaluated, otherwise else is evaluated.
94     This function is necessary for recursive definitions.
95     .TP
96     .BR "select(N, a1, a2, ..)"
97     return aN (N is rounded to the nearest integer).
98     This function provides array capabilities.
99     If
100     .I N
101     is zero, the number of available arguments is returned.
102     .TP
103     .BR "rand(x)"
104     compute a random number between 0 and 1 based on x.
105     .TP
106 greg 1.4 .BR "min(a1, a2, ..)"
107     return the minimum value from a list of arguments.
108     .TP
109     .BR "max(a1, a2, ..)"
110     return the maximum value from a list of arguments.
111     .TP
112 greg 1.1 .BR "floor(x)"
113     return largest integer not greater than x.
114     .TP
115     .BR "ceil(x)"
116     return smallest integer not less than x.
117     .TP
118     .BR "sqrt(x)"
119     return square root of x.
120     .TP
121     .BR "exp(x)"
122     compute e to the power of x (e approx = 2.718281828).
123     .TP
124     .BR "log(x)"
125     compute the logarithm of x to the base e.
126     .TP
127     .BR "log10(x)"
128     compute the logarithm of x to the base 10.
129     .TP
130     .BR "sin(x), cos(x), tan(x)"
131     trigonometric functions.
132     .TP
133     .BR "asin(x), acos(x), atan(x)"
134     inverse trigonometric functions.
135     .TP
136     .BR "atan2(y, x)"
137 greg 1.2 inverse tangent of y/x (range \-pi to pi).
138 greg 1.3 .SH ENVIRONMENT
139     RAYPATH the directories to check for auxiliary files.
140 greg 1.1 .SH AUTHOR
141     Greg Ward
142     .SH "SEE ALSO"
143     ev(1), rcalc(1), tabfunc(1)