applyed codingstyle

This commit is contained in:
boombuler 2013-02-23 16:18:02 +01:00
parent 8d419c3c95
commit c36afe506e

View File

@ -24,9 +24,9 @@ function wrapper() {
var MAX_LINK_COLOR = '#FF0000'; var MAX_LINK_COLOR = '#FF0000';
var Triangle = function (a, b, c) { var Triangle = function (a, b, c) {
this.a = a this.a = a;
this.b = b this.b = b;
this.c = c this.c = c;
var A = b.x - a.x, var A = b.x - a.x,
B = b.y - a.y, B = b.y - a.y,
@ -48,9 +48,7 @@ function wrapper() {
this.x = minx + dx this.x = minx + dx
this.y = miny + dy this.y = miny + dy
this.r = dx * dx + dy * dy this.r = dx * dx + dy * dy
} } else {
else {
this.x = (D*E - B*F) / G this.x = (D*E - B*F) / G
this.y = (A*F - C*E) / G this.y = (A*F - C*E) / G
dx = this.x - a.x dx = this.x - a.x
@ -78,21 +76,20 @@ function wrapper() {
} }
var dedup = function (edges) { var dedup = function (edges) {
var j = edges.length, var j = edges.length, a, b, i, m, n;
a, b, i, m, n
outer: while(j) { outer: while(j) {
b = edges[--j] b = edges[--j];
a = edges[--j] a = edges[--j];
i = j i = j;
while(i) { while(i) {
n = edges[--i] n = edges[--i];
m = edges[--i] m = edges[--i];
if((a === m && b === n) || (a === n && b === m)) { if((a === m && b === n) || (a === n && b === m)) {
edges.splice(j, 2) edges.splice(j, 2);
edges.splice(i, 2) edges.splice(i, 2);
j -= 2 j -= 2;
continue outer continue outer;
} }
} }
} }
@ -112,11 +109,13 @@ function wrapper() {
xmin = vertices[i].x, xmin = vertices[i].x,
xmax = vertices[0].x, xmax = vertices[0].x,
ymin = vertices[i].y, ymin = vertices[i].y,
ymax = ymin ymax = ymin;
while(i--) { while(i--) {
if(vertices[i].y < ymin) ymin = vertices[i].y if(vertices[i].y < ymin)
if(vertices[i].y > ymax) ymax = vertices[i].y ymin = vertices[i].y;
if(vertices[i].y > ymax)
ymax = vertices[i].y;
} }
/* Find a supertriangle, which is a triangle that surrounds all the /* Find a supertriangle, which is a triangle that surrounds all the
@ -141,69 +140,66 @@ function wrapper() {
], ],
closed = [], closed = [],
edges = [], edges = [],
j, a, b j, a, b;
/* Incrementally add each vertex to the mesh. */ /* Incrementally add each vertex to the mesh. */
i = vertices.length i = vertices.length;
while(i--) { while(i--) {
/* For each open triangle, check to see if the current point is /* For each open triangle, check to see if the current point is
* inside it's circumcircle. If it is, remove the triangle and add * inside it's circumcircle. If it is, remove the triangle and add
* it's edges to an edge list. */ * it's edges to an edge list. */
edges.length = 0 edges.length = 0;
j = open.length j = open.length;
while(j--) { while(j--) {
/* If this point is to the right of this triangle's circumcircle, /* If this point is to the right of this triangle's circumcircle,
* then this triangle should never get checked again. Remove it * then this triangle should never get checked again. Remove it
* from the open list, add it to the closed list, and skip. */ * from the open list, add it to the closed list, and skip. */
dx = vertices[i].x - open[j].x dx = vertices[i].x - open[j].x;
if(dx > 0 && dx * dx > open[j].r) { if(dx > 0 && dx * dx > open[j].r) {
closed.push(open[j]) closed.push(open[j]);
open.splice(j, 1) open.splice(j, 1);
continue continue;
} }
/* If not, skip this triangle. */ /* If not, skip this triangle. */
dy = vertices[i].y - open[j].y dy = vertices[i].y - open[j].y;
if(dx * dx + dy * dy > open[j].r) if(dx * dx + dy * dy > open[j].r)
continue continue;
/* Remove the triangle and add it's edges to the edge list. */ /* Remove the triangle and add it's edges to the edge list. */
edges.push( edges.push(
open[j].a, open[j].b, open[j].a, open[j].b,
open[j].b, open[j].c, open[j].b, open[j].c,
open[j].c, open[j].a open[j].c, open[j].a
) );
open.splice(j, 1) open.splice(j, 1);
} }
/* Remove any doubled edges. */ /* Remove any doubled edges. */
dedup(edges) dedup(edges);
/* Add a new triangle for each edge. */ /* Add a new triangle for each edge. */
j = edges.length j = edges.length;
while(j) { while(j) {
b = edges[--j] b = edges[--j];
a = edges[--j] a = edges[--j];
open.push(new Triangle(a, b, vertices[i])) open.push(new Triangle(a, b, vertices[i]));
} }
} }
/* Copy any remaining open triangles to the closed list, and then /* Copy any remaining open triangles to the closed list, and then
* remove any triangles that share a vertex with the supertriangle. */ * remove any triangles that share a vertex with the supertriangle. */
Array.prototype.push.apply(closed, open) Array.prototype.push.apply(closed, open);
i = closed.length i = closed.length;
while(i--) while(i--)
if(closed[i].a.__sentinel || if(closed[i].a.__sentinel || closed[i].b.__sentinel || closed[i].c.__sentinel)
closed[i].b.__sentinel || closed.splice(i, 1);
closed[i].c.__sentinel)
closed.splice(i, 1)
/* Yay, we're done! */ /* Yay, we're done! */
return closed return closed;
} }
var layer = null; var layer = null;
window.plugin.portalfolding.toggle = function() { window.plugin.portalfolding.toggle = function() {
@ -221,8 +217,10 @@ function wrapper() {
for (var key in window.portals) { for (var key in window.portals) {
var loc = window.portals[key].options.details.locationE6; var loc = window.portals[key].options.details.locationE6;
var nloc = { x: loc.lngE6, y: loc.latE6 }; var nloc = { x: loc.lngE6, y: loc.latE6 };
if (nloc.x < minX) minX = nloc.x; if (nloc.x < minX)
if (nloc.y < minX) minX = nloc.y; minX = nloc.x;
if (nloc.y < minX)
minX = nloc.y;
locations.push(nloc); locations.push(nloc);
} }