Point.st
changeset 4893 a645a54ced2a
parent 4891 56cd253f920b
child 4984 e20cd6bdc182
--- a/Point.st	Sun Oct 10 13:18:58 1999 +0200
+++ b/Point.st	Sun Oct 10 14:40:56 1999 +0200
@@ -102,6 +102,20 @@
     "Modified: 8.5.1996 / 20:01:50 / cg"
 !
 
+r:distance degrees:angle
+    "create and return a new point given polar coordinates.
+     The angle is given in degrees.
+     Added for Squeak compatibility"
+
+    ^ self r:distance angle:angle
+
+    "
+     Point r:100 degrees:90  
+    "
+
+    "Modified: 8.5.1996 / 20:01:50 / cg"
+!
+
 r:distance theta:angleInRadians
     "create and return a new point given polar coordinates.
      The angle is given in radians"
@@ -993,6 +1007,26 @@
     ^ (1 / x) @ (1 / y)
 !
 
+rotateBy:angle about:center
+    "Return a new point, generated by rotating the receiver
+     counterClockWise by some angle in radians around the given center point.
+     Even though Point.theta is measured CW, 
+     this rotates with the more conventional CCW interpretateion of angle."
+
+    |p r theta|
+
+    p := self - center.
+    r := p r.
+    theta := angle asFloat - p theta.
+    ^ (center x asFloat + (r * theta cos)) @
+      (center y asFloat - (r * theta sin))
+
+    "
+     (10@10) rotateBy:Float pi about:0@0  
+     (10@0) rotateBy:Float pi about:0@0  
+    "
+!
+
 scaledBy:aScale
     "return a new Point that is the product of the 
      receiver and scale (which is a Point or Number)."
@@ -1010,6 +1044,6 @@
 !Point class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.50 1999-10-09 16:11:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.51 1999-10-10 12:40:56 cg Exp $'
 ! !
 Point initialize!