Complex as extension of Point
Martin Snelgrove
snelgar at dissonance.com
Tue Oct 4 01:22:31 UTC 2005
I had also wondered about building Complex out of Point. The taste
issues here are for Smalltalk
experts, so what I'll do is try to contribute with a quick look at
the math.
Here's a table that describes some similarities and differences
between Complex and
Number & Point, respectively.
Function(s)
Number Point
+, - must
extend is correct
*,/ must
extend wrong, must override
real,imaginary must
extend aliases for x,y
reciprocal must
extend wrong, must override
a+ib write a + b
i a at b concise but nonstandard
printOn:
extend a at b concise but nonstandard
abs must
extend r, not abs
arg must
extend theta almost right: arbitrary for 0 at 0;
sloppy accuracy for 0 at 1, different root convention
sin, cos must
extend must extend
degreeCos, degreeSin copy from Float
interpolation leave to
user interpolateTo:at:
isZero must
extend is correct
|a -b| leave to
user a dist: b
rendering on plane use Point
is correct
= must
extend is correct
>, < etc. return
error? override, return error
adaptToNumber must extend
is wrong, should be ^ rcvr at 0 perform: selector with: self
asFloatPoint must
extend correct?
In the absence of guidance, I'm steaming ahead building on what's
already there. In the event that the stuff
needs to be moved around, I hope someone out there knows an easy way
of doing it.
regards
ws
On Sep 30, 2005, at 09.13, squeak-dev-
request at lists.squeakfoundation.org wrote:
> I may be missing something, but is there a specific reason why we
> do not
> implement complex numbers simply by extending Point ? it would make it
> easier to work with transformations on the complex plane where
> conversion between Point and Complex would happen all the time.
>
>
> Stef
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20051003/9021c20f/attachment.htm
More information about the Squeak-dev
mailing list
|