Problem with Point>>setR:degrees:
David N. Smith (IBM)
dnsmith at watson.ibm.com
Fri Jan 14 22:36:26 UTC 2000
All:
I've had a problem with Point>>#r:degrees:, which calls the instance
method #setR:degress:, which truncates the x and y values it computes:
setR: rho degrees: theta
| radians |
radians _ theta asFloat degreesToRadians.
x _ (rho asFloat * radians cos) asInteger.
y _ (rho asFloat * radians sin) asInteger.
Other point creation methods do not truncate (or round) values to integers.
The truncation causes the point to get 'smaller'. I was repeatedly
using #r:degrees: on points in a closed curve and the curve rapidly
shrunk down to nothing. Nice visual effect, but not what I wanted.
I suggest that the asInteger be removed from the method and that any
callers (there are 8-10 of them through Point>>#r:degrees:) be fixed
to truncate their arguments if that is the right thing to do.
An alternative is to use #rounded, but I have no idea what effect
that would have on my code or the other calls.
Any comments before I go make the changes? I'm currently using a copy
of #setR:degrees without the #asInteger and it works fine for my
application.
Dave
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author
and not of his employer.
More information about the Squeak-dev
mailing list
|