Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.math.points");
12
dojo.require("dojo.math");
13
dojo.math.points = {translate:function (a, b) {
14
	if (a.length != b.length) {
15
		dojo.raise("dojo.math.translate: points not same size (a:[" + a + "], b:[" + b + "])");
16
	}
17
	var c = new Array(a.length);
18
	for (var i = 0; i < a.length; i++) {
19
		c[i] = a[i] + b[i];
20
	}
21
	return c;
22
}, midpoint:function (a, b) {
23
	if (a.length != b.length) {
24
		dojo.raise("dojo.math.midpoint: points not same size (a:[" + a + "], b:[" + b + "])");
25
	}
26
	var c = new Array(a.length);
27
	for (var i = 0; i < a.length; i++) {
28
		c[i] = (a[i] + b[i]) / 2;
29
	}
30
	return c;
31
}, invert:function (a) {
32
	var b = new Array(a.length);
33
	for (var i = 0; i < a.length; i++) {
34
		b[i] = -a[i];
35
	}
36
	return b;
37
}, distance:function (a, b) {
38
	return Math.sqrt(Math.pow(b[0] - a[0], 2) + Math.pow(b[1] - a[1], 2));
39
}};
40