home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_200
/
232_01
/
point.st
< prev
next >
Wrap
Text File
|
1987-06-17
|
1KB
|
71 lines
Class Point :Magnitude
| xvalue yvalue |
[
< aPoint
^ (xvalue < aPoint x) and: [yvalue < aPoint y]
|
<= aPoint
^ (xvalue <= aPoint x) and: [yvalue < aPoint y]
|
>= aPoint
^ (xvalue >= aPoint x) and: [yvalue >= aPoint y]
|
= aPoint
^ (xvalue = aPoint x) and: [yvalue = aPoint y]
|
* scale
^ (Point new x: (xvalue * scale)) y: (yvalue * scale)
|
+ delta
^ (Point new x: (xvalue + delta x)) y: (yvalue + delta y)
|
- delta
^ (Point new x: (xvalue - delta x)) y: (yvalue - delta y)
|
/ scale
^ (Point new x: (xvalue / scale)) y: (yvalue / scale)
|
// scale
^ (Point new x: (xvalue // scale)) y: (yvalue // scale)
|
abs
^ (Point new x: xvalue abs) y: (yvalue abs)
|
asString
^ xvalue asString , ' @ ' , (yvalue asString)
|
dist: aPoint
^ ((xvalue - aPoint x) squared +
(yvalue - aPoint y) squared) sqrt
|
max: aPoint
^ (Point new x: (xvalue max: aPoint x))
y: (yvalue max: aPoint y)
|
min: aPoint
^ (Point new x: (xvalue min: aPoint x))
y: (yvalue min: aPoint y)
|
printString
^ xvalue printString , ' @ ' , (yvalue printString)
|
transpose
^ (Point new x: yvalue) y: xvalue
|
x
^ xvalue
|
x: aValue
xvalue <- aValue
|
x: xValue y: yValue
xvalue <- xValue.
yvalue <- yValue
|
y
^ yvalue
|
y: aValue
yvalue <- aValue
]