#807 - give geometries a resize method - examples and tests for demonstration

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3631 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-07-06 20:32:22 +00:00
parent 0d596fbb03
commit c2fcb22d98
5 changed files with 141 additions and 0 deletions

View File

@@ -103,6 +103,30 @@
"rotate 1/8 turn correctly")
}
function test_Point_resize(t) {
t.plan(2);
var tolerance = 1e-10;
var x = 100 * Math.random();
var y = 100 * Math.random();
var point = new OpenLayers.Geometry.Point(x, y);
var i = 100 * Math.random();
var j = 100 * Math.random();
var origin = new OpenLayers.Geometry.Point(i, j);
var scale = 10 * Math.random();
var oldDistance = origin.distanceTo(point);
point.resize(scale, origin);
var newDistance = origin.distanceTo(point);
t.ok((origin.x == i) && (origin.y == j),
"resize leaves the origin untouched");
t.ok((((newDistance / oldDistance) - scale) / scale) < tolerance,
"resize moves points the correct distance from the origin")
}
function test_Point_equals(t) {
t.plan(3);