--- a/Point.st Fri Nov 13 06:40:14 2015 +0100
+++ b/Point.st Sat Nov 14 06:43:31 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -661,7 +663,7 @@
abs
"return a new point with my coordinates taken from the absolute values."
- ^ (x abs) @ (y abs)
+ ^ self class x:(x abs) y:(y abs)
!
ceiling
@@ -672,7 +674,7 @@
^ self
].
- ^ (x ceiling) @ (y ceiling)
+ ^ self class x:x ceiling y:y ceiling.
!
floor
@@ -683,7 +685,7 @@
^ self
].
- ^ (x floor) @ (y floor)
+ ^ self class x:(x floor) y:(y floor)
!
quadrant
@@ -744,7 +746,7 @@
(x isInteger and:[y isInteger]) ifTrue: [
^ self
].
- ^ (x rounded) @ (y rounded)
+ ^ self class x:(x rounded) y:(y rounded)
"
(1.5 @ 2.6) rounded
@@ -767,7 +769,7 @@
^ self
].
- ^ (x truncated) @ (y truncated)
+ ^ self class x:(x truncated) y:(y truncated)
! !
!Point methodsFor:'point functions'!
@@ -1034,75 +1036,75 @@
"speedup for common cases ..."
(scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x * scale x) y:(y * scale y)
+ ^ self class x:(x * scale x) y:(y * scale y)
].
(scale isMemberOf:SmallInteger) ifTrue:[
- ^ Point x:(x * scale) y:(y * scale)
+ ^ self class x:(x * scale) y:(y * scale)
].
scale isNumber ifTrue:[
- ^ Point x:(x * scale) y:(y * scale)
+ ^ self class x:(x * scale) y:(y * scale)
].
"this is the general (& clean) code ..."
scalePoint := scale asPoint.
- ^ (x * scalePoint x) @ (y * scalePoint y)
+ ^ self class x:(x * scalePoint x) y:(y * scalePoint y)
"Modified: 25.1.1997 / 17:28:11 / cg"
!
-+ scale
++ translation
"Return a new Point that is the sum of the
- receiver and scale (which is a Point or Number)."
+ receiver and translation (which is a Point or Number)."
- |scalePoint|
+ |translationPoint|
"speedup for common cases ..."
- (scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x + scale x) y:(y + scale y)
+ (translation isMemberOf:Point) ifTrue:[
+ ^ self class x:(x + translation x) y:(y + translation y)
].
- (scale isMemberOf:SmallInteger) ifTrue:[
+ (translation isMemberOf:SmallInteger) ifTrue:[
"/ same as below, but stc can do better here
- ^ Point x:(x + scale) y:(y + scale)
+ ^ self class x:(x + translation) y:(y + translation)
].
- scale isNumber ifTrue:[
- ^ Point x:(x + scale) y:(y + scale)
+ translation isNumber ifTrue:[
+ ^ self class x:(x + translation) y:(y + translation)
].
"this is the general (& clean) code ..."
- scalePoint := scale asPoint.
- ^ (x + scalePoint x) @ (y + scalePoint y)
+ translationPoint := translation asPoint.
+ ^ self class x:(x + translationPoint x) y:(y + translationPoint y).
"Modified: 25.1.1997 / 17:27:46 / cg"
!
-- scale
+- translation
"Return a new Point that is the difference of the
- receiver and scale (which is a Point or Number)."
+ receiver and translation (which is a Point or Number)."
- |scalePoint|
+ |translationPoint|
"speedup for common cases ..."
- (scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x - scale x) y:(y - scale y)
+ (translation isMemberOf:Point) ifTrue:[
+ ^ self class x:(x - translation x) y:(y - translation y)
].
- (scale isMemberOf:SmallInteger) ifTrue:[
- "/ same as below, but stc can do better here
- ^ Point x:(x - scale) y:(y - scale)
+ (translation isMemberOf:SmallInteger) ifTrue:[
+ "/ same as below, but stc can do better here
+ ^ self class x:(x - translation) y:(y - translation)
].
- scale isNumber ifTrue:[
- ^ Point x:(x - scale) y:(y - scale)
+ translation isNumber ifTrue:[
+ ^ self class x:(x - translation) y:(y - translation)
].
"this is the general (& clean) code ..."
- scalePoint := scale asPoint.
- ^ (x - scalePoint x) @ (y - scalePoint y)
+ translationPoint := translation asPoint.
+ ^ self class x:(x - translationPoint x) y:(y - translationPoint y).
- "Modified: 25.1.1997 / 17:27:40 / cg"
+ "Modified: 25.1.1997 / 17:27:46 / cg"
!
/ scale
@@ -1114,16 +1116,16 @@
"speedup for common cases ..."
(scale isMemberOf:Point) ifTrue:[
- ^ (x / scale x) @ (y / scale y)
+ self class x:(x / scale x) y:(y / scale y)
].
scale isNumber ifTrue:[
- ^ (x / scale) @ (y / scale)
+ ^ self class x:(x / scale) y:(y / scale)
].
"this is the general (& clean) code ..."
scalePoint := scale asPoint.
- ^ (x / scalePoint x) @ (y / scalePoint y)
+ ^ self class x:(x / scalePoint x) y:(y / scalePoint y)
!
// scale
@@ -1133,21 +1135,25 @@
|scalePoint|
scalePoint := scale asPoint.
- ^ (x // scalePoint x) @ (y // scalePoint y)
+ ^ self class x:(x // scalePoint x) y:(y // scalePoint y)
!
negated
"return a new point with my coordinates negated
i.e. the receiver mirrored at the origin"
- ^ (x negated) @ (y negated)
+ ^ self class x:x negated y:y negated
+
+ "
+ (1 @ 1) negated
+ "
!
reciprocal
"return a new point where the coordinates are
the reciproce of mine"
- ^ (1 / x) @ (1 / y)
+ ^ self class x:(1 / x) y:(1 / y)
!
rotateBy:angle about:center
@@ -1161,8 +1167,8 @@
p := self - center.
r := p r.
theta := angle asFloat - p theta.
- ^ (center x asFloat + (r * theta cos)) @
- (center y asFloat - (r * theta sin))
+ ^ self class x:(center x asFloat + (r * theta cos))
+ y:(center y asFloat - (r * theta sin))
"
(10@10) rotateBy:Float pi about:0@0