Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.math.points");
14
dojo.require("dojo.math");
15
dojo.math.points = {translate:function (a, b) {
16
	if (a.length != b.length) {
17
		dojo.raise("dojo.math.translate: points not same size (a:[" + a + "], b:[" + b + "])");
18
	}
19
	var c = new Array(a.length);
20
	for (var i = 0; i < a.length; i++) {
21
		c[i] = a[i] + b[i];
22
	}
23
	return c;
24
}, midpoint:function (a, b) {
25
	if (a.length != b.length) {
26
		dojo.raise("dojo.math.midpoint: points not same size (a:[" + a + "], b:[" + b + "])");
27
	}
28
	var c = new Array(a.length);
29
	for (var i = 0; i < a.length; i++) {
30
		c[i] = (a[i] + b[i]) / 2;
31
	}
32
	return c;
33
}, invert:function (a) {
34
	var b = new Array(a.length);
35
	for (var i = 0; i < a.length; i++) {
36
		b[i] = -a[i];
37
	}
38
	return b;
39
}, distance:function (a, b) {
40
	return Math.sqrt(Math.pow(b[0] - a[0], 2) + Math.pow(b[1] - a[1], 2));
41
}};
42