1
0
Bläddra i källkod

Add method to Point

Steven Rémot 7 år sedan
förälder
incheckning
e32caa48e1
4 ändrade filer med 474 tillägg och 76 borttagningar
  1. 192 0
      src/Kernel-Objects.js
  2. 41 0
      src/Kernel-Objects.st
  3. 214 68
      src/Kernel-Tests.js
  4. 27 8
      src/Kernel-Tests.st

+ 192 - 0
src/Kernel-Objects.js

@@ -3616,6 +3616,30 @@ messageSends: []
 }),
 $globals.Number);
 
+$core.addMethod(
+$core.method({
+selector: "arcTan:",
+protocol: "mathematical functions",
+fn: function(aNumber){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return Math.atan2(self, aNumber);;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"arcTan:",{aNumber:aNumber},$globals.Number)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aNumber"],
+source: "arcTan: aNumber\x0a\x09<inlineJS: 'return Math.atan2(self, aNumber);'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Number);
+
 $core.addMethod(
 $core.method({
 selector: "asJavaScriptObject",
@@ -5340,6 +5364,29 @@ messageSends: ["and:", ">=", "x", "y"]
 }),
 $globals.Point);
 
+$core.addMethod(
+$core.method({
+selector: "angle",
+protocol: "geometry",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv($self._y())._arcTan_($self._x());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"angle",{},$globals.Point)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "angle\x0a\x09^ self y arcTan: self x",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["arcTan:", "y", "x"]
+}),
+$globals.Point);
+
 $core.addMethod(
 $core.method({
 selector: "asPoint",
@@ -5416,6 +5463,34 @@ messageSends: ["-", "x", "y", "sqrt", "+", "*"]
 }),
 $globals.Point);
 
+$core.addMethod(
+$core.method({
+selector: "dotProduct:",
+protocol: "point functions",
+fn: function(aPoint){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($self["@x"]).__star($recv(aPoint)._x());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["*"]=1;
+//>>excludeEnd("ctx");
+return $recv($1).__plus($recv($self["@y"]).__star($recv(aPoint)._y()));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"dotProduct:",{aPoint:aPoint},$globals.Point)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aPoint"],
+source: "dotProduct: aPoint\x0a\x09^ (x * aPoint x) + (y * aPoint y)",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["+", "*", "x", "y"]
+}),
+$globals.Point);
+
 $core.addMethod(
 $core.method({
 selector: "extent:",
@@ -5439,6 +5514,94 @@ messageSends: ["origin:extent:"]
 }),
 $globals.Point);
 
+$core.addMethod(
+$core.method({
+selector: "normal",
+protocol: "point functions",
+fn: function(){
+var self=this,$self=this;
+var n,d;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $4,$3,$6,$5,$2,$1;
+n=$recv($recv($self["@y"])._negated()).__at($self["@x"]);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=1;
+//>>excludeEnd("ctx");
+$4=$recv(n)._x();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["x"]=1;
+//>>excludeEnd("ctx");
+$3=$recv($4).__star($recv(n)._x());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["*"]=1;
+//>>excludeEnd("ctx");
+$6=$recv(n)._y();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["y"]=1;
+//>>excludeEnd("ctx");
+$5=$recv($6).__star($recv(n)._y());
+d=$recv($3).__plus($5);
+$2=d;
+$1=$recv($2).__eq((0));
+if($core.assert($1)){
+return (-1).__at((0));
+}
+return $recv(n).__slash($recv(d)._sqrt());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"normal",{n:n,d:d},$globals.Point)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "normal\x0a\x09\x22Answer a Point representing the unit vector rotated 90 deg clockwise. For the zero point return -1@0.\x22\x0a\x0a\x09| n d |\x0a\x09n := y negated @ x.\x0a\x09(d := (n x * n x + (n y * n y))) = 0\x0a\x09\x09 ifTrue: [ ^ -1 @0 ].\x0a\x09^ n / d sqrt",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["@", "negated", "ifTrue:", "=", "+", "*", "x", "y", "/", "sqrt"]
+}),
+$globals.Point);
+
+$core.addMethod(
+$core.method({
+selector: "normalized",
+protocol: "point functions",
+fn: function(){
+var self=this,$self=this;
+var r;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$3;
+r=$self._r();
+$1=$recv(r).__eq((0));
+if($core.assert($1)){
+$2=$recv($globals.Point)._x_y_((0),(0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["x:y:"]=1;
+//>>excludeEnd("ctx");
+return $2;
+} else {
+$3=$recv($self["@x"]).__slash(r);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["/"]=1;
+//>>excludeEnd("ctx");
+return $recv($globals.Point)._x_y_($3,$recv($self["@y"]).__slash(r));
+}
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"normalized",{r:r},$globals.Point)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "normalized\x0a\x09| r |\x0a\x09r := self r.\x0a\x09\x0a\x09r = 0\x0a\x09\x09ifTrue: [ ^ Point x: 0 y: 0 ]\x0a\x09\x09ifFalse: [ ^ Point x: x / r y: y / r ]",
+referencedClasses: ["Point"],
+//>>excludeEnd("ide");
+messageSends: ["r", "ifTrue:ifFalse:", "=", "x:y:", "/"]
+}),
+$globals.Point);
+
 $core.addMethod(
 $core.method({
 selector: "printOn:",
@@ -5481,6 +5644,35 @@ messageSends: ["printOn:", "nextPutAll:", "ifTrue:", "and:", "notNil", "negative
 }),
 $globals.Point);
 
+$core.addMethod(
+$core.method({
+selector: "r",
+protocol: "polar coordinates",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$1;
+$2=$recv($self["@x"]).__star($self["@x"]);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["*"]=1;
+//>>excludeEnd("ctx");
+$1=$recv($2).__plus($recv($self["@y"]).__star($self["@y"]));
+return $recv($1)._sqrt();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"r",{},$globals.Point)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "r\x0a\x09^ ((x * x) + (y * y)) sqrt",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["sqrt", "+", "*"]
+}),
+$globals.Point);
+
 $core.addMethod(
 $core.method({
 selector: "rectangle:",

+ 41 - 0
src/Kernel-Objects.st

@@ -1014,6 +1014,10 @@ arcTan
 	<inlineJS: 'return Math.atan(self);'>
 !
 
+arcTan: aNumber
+	<inlineJS: 'return Math.atan2(self, aNumber);'>
+!
+
 cos
 	<inlineJS: 'return Math.cos(self);'>
 !
@@ -1223,6 +1227,43 @@ asPoint
 	^ self
 ! !
 
+!Point methodsFor: 'geometry'!
+
+angle
+	^ self y arcTan: self x
+! !
+
+!Point methodsFor: 'point functions'!
+
+dotProduct: aPoint
+	^ (x * aPoint x) + (y * aPoint y)
+!
+
+normal
+	"Answer a Point representing the unit vector rotated 90 deg clockwise. For the zero point return -1@0."
+
+	| n d |
+	n := y negated @ x.
+	(d := (n x * n x + (n y * n y))) = 0
+		 ifTrue: [ ^ -1 @0 ].
+	^ n / d sqrt
+!
+
+normalized
+	| r |
+	r := self r.
+	
+	r = 0
+		ifTrue: [ ^ Point x: 0 y: 0 ]
+		ifFalse: [ ^ Point x: x / r y: y / r ]
+! !
+
+!Point methodsFor: 'polar coordinates'!
+
+r
+	^ ((x * x) + (y * y)) sqrt
+! !
+
 !Point methodsFor: 'printing'!
 
 printOn: aStream

+ 214 - 68
src/Kernel-Tests.js

@@ -13824,11 +13824,12 @@ $core.addMethod(
 $core.method({
 selector: "testTrigonometry",
 protocol: "tests",
-fn: function (){
+fn: function(){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
+var $1;
 $self._assert_equals_((0)._cos(),(1));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["assert:equals:"]=1;
@@ -13850,6 +13851,18 @@ $self._assert_equals_((0)._arcSin(),(0));
 $ctx1.sendIdx["assert:equals:"]=5;
 //>>excludeEnd("ctx");
 $self._assert_equals_((0)._arcTan(),(0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=6;
+//>>excludeEnd("ctx");
+$1=(0)._arcTan_((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["arcTan:"]=1;
+//>>excludeEnd("ctx");
+$self._assert_equals_($1,(0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=7;
+//>>excludeEnd("ctx");
+$self._assert_equals_((1)._arcTan_((0)),$recv($recv($globals.Number)._pi()).__slash((2)));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"testTrigonometry",{},$globals.NumberTest)});
@@ -13857,10 +13870,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testTrigonometry\x0a\x09self assert: 0 cos equals: 1.\x0a\x09self assert: 0 sin equals: 0.\x0a\x09self assert: 0 tan equals: 0.\x0a\x09self assert: 1 arcCos equals: 0.\x0a\x09self assert: 0 arcSin equals: 0.\x0a\x09self assert: 0 arcTan equals: 0.",
-referencedClasses: [],
+source: "testTrigonometry\x0a\x09self assert: 0 cos equals: 1.\x0a\x09self assert: 0 sin equals: 0.\x0a\x09self assert: 0 tan equals: 0.\x0a\x09self assert: 1 arcCos equals: 0.\x0a\x09self assert: 0 arcSin equals: 0.\x0a\x09self assert: 0 arcTan equals: 0.\x0a\x09\x0a\x09self assert: (0 arcTan: 1) equals: 0.\x0a\x09self assert: (1 arcTan: 0) equals: (Number pi / 2)",
+referencedClasses: ["Number"],
 //>>excludeEnd("ide");
-messageSends: ["assert:equals:", "cos", "sin", "tan", "arcCos", "arcSin", "arcTan"]
+messageSends: ["assert:equals:", "cos", "sin", "tan", "arcCos", "arcSin", "arcTan", "arcTan:", "/", "pi"]
 }),
 $globals.NumberTest);
 
@@ -14460,6 +14473,30 @@ messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"]
 }),
 $globals.PointTest);
 
+$core.addMethod(
+$core.method({
+selector: "testAngle",
+protocol: "tests",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._assert_equals_($recv((-1).__at((0)))._angle(),$recv($globals.Number)._pi());
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testAngle",{},$globals.PointTest)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testAngle\x0a\x09self assert: (-1@0) angle equals: Number pi",
+referencedClasses: ["Number"],
+//>>excludeEnd("ide");
+messageSends: ["assert:equals:", "angle", "@", "pi"]
+}),
+$globals.PointTest);
+
 $core.addMethod(
 $core.method({
 selector: "testArithmetic",
@@ -14697,40 +14734,31 @@ $globals.PointTest);
 
 $core.addMethod(
 $core.method({
-selector: "testCorner",
+selector: "testDotProduct",
 protocol: "tests",
 fn: function(){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $2,$3,$1,$5,$4;
-$2=(1).__at((1));
+var $2,$1;
+$2=(2).__at((3));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["@"]=1;
 //>>excludeEnd("ctx");
-$3=(2).__at((2));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["@"]=2;
-//>>excludeEnd("ctx");
-$1=$recv($2)._corner_($3);
-$5=(1).__at((1));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["@"]=3;
-//>>excludeEnd("ctx");
-$4=$recv($globals.Rectangle)._origin_corner_($5,(2).__at((2)));
-$self._assert_equals_($1,$4);
+$1=$recv($2)._dotProduct_((3).__at((7)));
+$self._assert_equals_($1,(27));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"testCorner",{},$globals.PointTest)});
+}, function($ctx1) {$ctx1.fill(self,"testDotProduct",{},$globals.PointTest)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testCorner\x0a\x09self assert: (1@1 corner: 2@2) equals: (Rectangle origin: 1@1 corner: 2@2).",
-referencedClasses: ["Rectangle"],
+source: "testDotProduct\x0a\x09self assert: (2@3 dotProduct: 3@7) equals: 27",
+referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["assert:equals:", "corner:", "@", "origin:corner:"]
+messageSends: ["assert:equals:", "dotProduct:", "@"]
 }),
 $globals.PointTest);
 
@@ -14777,45 +14805,6 @@ messageSends: ["assert:", "=", "@", "deny:"]
 }),
 $globals.PointTest);
 
-$core.addMethod(
-$core.method({
-selector: "testExtent",
-protocol: "tests",
-fn: function(){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $2,$3,$1,$5,$4;
-$2=(1).__at((1));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["@"]=1;
-//>>excludeEnd("ctx");
-$3=(2).__at((2));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["@"]=2;
-//>>excludeEnd("ctx");
-$1=$recv($2)._extent_($3);
-$5=(1).__at((1));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["@"]=3;
-//>>excludeEnd("ctx");
-$4=$recv($globals.Rectangle)._origin_extent_($5,(2).__at((2)));
-$self._assert_equals_($1,$4);
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"testExtent",{},$globals.PointTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "testExtent\x0a\x09self assert: (1@1 extent: 2@2) equals: (Rectangle origin: 1@1 extent: 2@2)",
-referencedClasses: ["Rectangle"],
-//>>excludeEnd("ide");
-messageSends: ["assert:equals:", "extent:", "@", "origin:extent:"]
-}),
-$globals.PointTest);
-
 $core.addMethod(
 $core.method({
 selector: "testNew",
@@ -14886,14 +14875,127 @@ $globals.PointTest);
 
 $core.addMethod(
 $core.method({
-selector: "testRectangle",
+selector: "testNormal",
 protocol: "tests",
 fn: function(){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $2,$3,$1,$5,$4;
+var $2,$1;
+$2=(1).__at((0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=1;
+//>>excludeEnd("ctx");
+$1=$recv($2)._normal();
+$self._assert_equals_($1,(0).__at((1)));
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testNormal",{},$globals.PointTest)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testNormal\x0a\x09self assert: (1@0) normal equals: 0@1",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["assert:equals:", "normal", "@"]
+}),
+$globals.PointTest);
+
+$core.addMethod(
+$core.method({
+selector: "testNormalized",
+protocol: "tests",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$1,$3,$5,$4;
+$2=(0).__at((2));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=1;
+//>>excludeEnd("ctx");
+$1=$recv($2)._normalized();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["normalized"]=1;
+//>>excludeEnd("ctx");
+$3=(0).__at((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=2;
+//>>excludeEnd("ctx");
+$self._assert_equals_($1,$3);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=1;
+//>>excludeEnd("ctx");
+$5=(0).__at((0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=3;
+//>>excludeEnd("ctx");
+$4=$recv($5)._normalized();
+$self._assert_equals_($4,(0).__at((0)));
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testNormalized",{},$globals.PointTest)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testNormalized\x0a\x09self assert: (0@2) normalized equals: 0@1.\x0a\x09self assert: (0@0) normalized equals: 0@0.",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["assert:equals:", "normalized", "@"]
+}),
+$globals.PointTest);
+
+$core.addMethod(
+$core.method({
+selector: "testPolarCoordinates",
+protocol: "tests",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$1;
+$2=(1).__at((0));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=1;
+//>>excludeEnd("ctx");
+$1=$recv($2)._r();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["r"]=1;
+//>>excludeEnd("ctx");
+$self._assert_equals_($1,(1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=1;
+//>>excludeEnd("ctx");
+$self._assert_equals_($recv((0).__at((0)))._r(),(0));
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testPolarCoordinates",{},$globals.PointTest)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testPolarCoordinates\x0a\x09self assert: (1@0) r equals: 1.\x0a\x09self assert: (0@0) r equals: 0.",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["assert:equals:", "r", "@"]
+}),
+$globals.PointTest);
+
+$core.addMethod(
+$core.method({
+selector: "testRectangleCreation",
+protocol: "tests",
+fn: function(){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$3,$1,$5,$6,$4,$8,$9,$7,$11,$12,$10,$14,$15,$13,$17,$16;
 $2=(1).__at((1));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["@"]=1;
@@ -14902,24 +15004,68 @@ $3=(2).__at((2));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["@"]=2;
 //>>excludeEnd("ctx");
-$1=$recv($2)._rectangle_($3);
+$1=$recv($2)._corner_($3);
 $5=(1).__at((1));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["@"]=3;
 //>>excludeEnd("ctx");
-$4=$recv($globals.Rectangle)._point_point_($5,(2).__at((2)));
+$6=(2).__at((2));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=4;
+//>>excludeEnd("ctx");
+$4=$recv($globals.Rectangle)._origin_corner_($5,$6);
 $self._assert_equals_($1,$4);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=1;
+//>>excludeEnd("ctx");
+$8=(1).__at((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=5;
+//>>excludeEnd("ctx");
+$9=(2).__at((2));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=6;
+//>>excludeEnd("ctx");
+$7=$recv($8)._rectangle_($9);
+$11=(1).__at((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=7;
+//>>excludeEnd("ctx");
+$12=(2).__at((2));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=8;
+//>>excludeEnd("ctx");
+$10=$recv($globals.Rectangle)._point_point_($11,$12);
+$self._assert_equals_($7,$10);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["assert:equals:"]=2;
+//>>excludeEnd("ctx");
+$14=(1).__at((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=9;
+//>>excludeEnd("ctx");
+$15=(2).__at((2));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=10;
+//>>excludeEnd("ctx");
+$13=$recv($14)._extent_($15);
+$17=(1).__at((1));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["@"]=11;
+//>>excludeEnd("ctx");
+$16=$recv($globals.Rectangle)._origin_extent_($17,(2).__at((2)));
+$self._assert_equals_($13,$16);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"testRectangle",{},$globals.PointTest)});
+}, function($ctx1) {$ctx1.fill(self,"testRectangleCreation",{},$globals.PointTest)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testRectangle\x0a\x09self assert: (1@1 rectangle: 2@2) equals: (Rectangle point: 1@1 point: 2@2)",
+source: "testRectangleCreation\x0a\x09self assert: (1@1 corner: 2@2) equals: (Rectangle origin: 1@1 corner: 2@2).\x0a\x09self assert: (1@1 rectangle: 2@2) equals: (Rectangle point: 1@1 point: 2@2).\x0a\x09self assert: (1@1 extent: 2@2) equals: (Rectangle origin: 1@1 extent: 2@2)",
 referencedClasses: ["Rectangle"],
 //>>excludeEnd("ide");
-messageSends: ["assert:equals:", "rectangle:", "@", "point:point:"]
+messageSends: ["assert:equals:", "corner:", "@", "origin:corner:", "rectangle:", "point:point:", "extent:", "origin:extent:"]
 }),
 $globals.PointTest);
 

+ 27 - 8
src/Kernel-Tests.st

@@ -2497,6 +2497,9 @@ testTrigonometry
 	self assert: 1 arcCos equals: 0.
 	self assert: 0 arcSin equals: 0.
 	self assert: 0 arcTan equals: 0.
+	
+	self assert: (0 arcTan: 1) equals: 0.
+	self assert: (1 arcTan: 0) equals: (Number pi / 2)
 !
 
 testTruncated
@@ -2620,6 +2623,10 @@ testAccessing
 	self assert: (Point new y: 4) y equals: 4
 !
 
+testAngle
+	self assert: (-1@0) angle equals: Number pi
+!
+
 testArithmetic
 	self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
 	self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
@@ -2645,8 +2652,8 @@ testComparison
 	self deny: 4@5 >= (5@5)
 !
 
-testCorner
-	self assert: (1@1 corner: 2@2) equals: (Rectangle origin: 1@1 corner: 2@2).
+testDotProduct
+	self assert: (2@3 dotProduct: 3@7) equals: 27
 !
 
 testEgality
@@ -2654,10 +2661,6 @@ testEgality
 	self deny: 3@5 = (3@6)
 !
 
-testExtent
-	self assert: (1@1 extent: 2@2) equals: (Rectangle origin: 1@1 extent: 2@2)
-!
-
 testNew
 
 	self assert: (Point new x: 3) y equals: nil.
@@ -2666,8 +2669,24 @@ testNew
 	self deny: (Point new y: 4) y = 0
 !
 
-testRectangle
-	self assert: (1@1 rectangle: 2@2) equals: (Rectangle point: 1@1 point: 2@2)
+testNormal
+	self assert: (1@0) normal equals: 0@1
+!
+
+testNormalized
+	self assert: (0@2) normalized equals: 0@1.
+	self assert: (0@0) normalized equals: 0@0.
+!
+
+testPolarCoordinates
+	self assert: (1@0) r equals: 1.
+	self assert: (0@0) r equals: 0.
+!
+
+testRectangleCreation
+	self assert: (1@1 corner: 2@2) equals: (Rectangle origin: 1@1 corner: 2@2).
+	self assert: (1@1 rectangle: 2@2) equals: (Rectangle point: 1@1 point: 2@2).
+	self assert: (1@1 extent: 2@2) equals: (Rectangle origin: 1@1 extent: 2@2)
 !
 
 testTranslateBy