> Tadziu Hoffmann wrote:
> a better definition would have been:
> define d2r {($1)*pi/180}
>
> Yes. Macros are expanded by simple textual substitution. They are
> totally disconnected from the language syntax. It is a cardinal
> rule that parameters which you see as subexpressions in formulas
Tadziu Hoffmann wrote:
a better definition would have been:
define d2r {($1)*pi/180}
Yes. Macros are expanded by simple textual substitution. They are totally
disconnected from the language syntax. It is a cardinal rule that parameters
which you see as subexpressions in formulas be parenthesized
> define d2r {$1*pi/180}
>
> t = d2r(15.0+0.5*i)
"define" being a (text-replacement) macro facility,
this can be understood as follows:
t = d2r(15.0+0.5*i)
= 15.0+0.5*i*pi/180
so a better definition would have been:
define d2r {($1)*pi/180}
I think similar pitfalls exist with cpp macr
Greetings All!
I was recently wanting to draw someline segments along radii
of a circle, at series of angles. Since I wanted to "think
in degrees", while the sin() and cos() functions work in
radians, I defined a function in pic according to:
.PS
pi = 4*atan2(1,1)
define d2r {$1*pi/180}
.PE
Then