Page 2 of 2

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 19:53
by Beherith
sqrt(2)/2

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 20:11
by SinbadEV
Beherith wrote:sqrt(2)/2
oops... I didn't notice you post... I worked it out to r.sqrt(3) which was right (my circles have a radius of 50 and the offset of each row is ~86.6 so I've used 87)...
and I don't see what "sqrt(2)/2" is supposed to mean... where's the variable?

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 20:25
by Beherith
whoops, my bad, it is sqrt(3). Height of equilateral triangle. so the answer is sqrt(3). You get no variable because you asked for ratio.

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 20:53
by zwzsg
SinbadEV wrote:what is the ratio of vertical offset to radius for the second row in a hexagonal latice?
Ambigious question.

1) What kind of hexagonal lattice? There are two non-retarded orientations:

Do you mean:

Image

Or

Image


2) Which second row do you mean? The second row that is vertically aligned, or the second row that closer but shifted?

Image

Or

Image


The answers are 5/2, 3/2, sqrt(3), sqrt(3)/2.


SinbadEV wrote:where's the variable?
You asked for a ratio. For the ratio h/r. So there is no r. Ask about h expressed in function of r if that is what you want.

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 21:17
by SinbadEV
Now I feel bad for having figured it out before people gave me intelligent responses... thanks for the effort anyways... and @zwzsg since you know what I'm talking about, do any of the mentioned numbers come out to finite ratios for the "closer but horizontally offset next row"?

also, I had forgotten I was asking for a ratio... I get it now.

edit and attachment:
This is the grid I'm using right now...
Image
To move around the grid you have 6 directions
NW = Up
NE = Up-Right
E = Right
SE = Down
SW = Down-Left
W = Left

Re: I have game idea, please make it for me...

Posted: 31 Mar 2011, 23:05
by SinbadEV
In case you were wondering how freaking fast javascript is, check out my test page... it does the following every time you move your mouse:

Code: Select all

		function intersects(x, y, cx, cy, r) {
			dx = x-cx
			dy = y-cy
			return dx*dx+dy*dy <= r*r
		}

		function mouseMove(e)
		{
			var mouseX=0, mouseY=0;

			if(e.offsetX) {
				mouseX = e.offsetX;
				mouseY = e.offsetY;
			}
			else if(e.layerX) {
				mouseX = e.layerX;
				mouseY = e.layerY;
			}

			/* do something with mouseX/mouseY */
			var coords=document.getElementById("coords");
			coords.innerHTML = mouseX+", "+mouseY;
			var found = false;
			for (x=0;x<x_cols;x++) {
				for (y=0;y<y_rows;y++) {
					
					cxt.fillStyle="#000000";
					coordText = "("+x+","+y+")";
					metrics = cxt.measureText(coordText)
					wo = Math.floor(metrics.width/2);
					if (intersects(mouseX,mouseY,x*2*r+r+(y*r),y*o+r, r) && !found) {
						data.innerHTML = x+", "+y;
						found = true;
					}
					
				}
			}
			if (!found) {data.innerHTML = "none"};
		}
and there is no perceptible lag

edit: and don't bother pointing out that a bunch of the stuff it's doing is redundant... I've fixed it, it looks like this now

Code: Select all

		function intersects(x, y, cx, cy, r) {
			dx = x-cx
			dy = y-cy
			return dx*dx+dy*dy <= r*r
		}

		function mouseMove(e)
		{
			var mouseX=0, mouseY=0;

			if(e.offsetX) {
				mouseX = e.offsetX;
				mouseY = e.offsetY;
			}
			else if(e.layerX) {
				mouseX = e.layerX;
				mouseY = e.layerY;
			}

			/* do something with mouseX/mouseY */
			coords.innerHTML = mouseX+", "+mouseY;
			var found = false;
			for (x=0;x<x_cols;x++) {
				for (y=0;y<y_rows;y++) {
					if (intersects(mouseX,mouseY,x*2*r+r+(y*r),y*o+r, r) && !found) {
						data.innerHTML = x+", "+y;
						found = true;
					}
					
				}
			}
			if (!found) {data.innerHTML = "none"};
		}

Re: I have game idea, please make it for me...

Posted: 01 Apr 2011, 14:33
by Caydr
How many of these threads have you made, Sinbad? You're making me feel inadequate.

Re: I have game idea, please make it for me...

Posted: 01 Apr 2011, 15:32
by PicassoCT
This one is diffrent, he contributed java-code, the usual un-productive pingpong and trolling ended for a moment. Sinbad can do it, i see contribooty. If its good i have the right to steal it.

Re: I have game idea, please make it for me...

Posted: 01 Apr 2011, 18:27
by SinbadEV
due to popular demand I have have shifted my place for posting of crazy ideas to http://sinbadev-benjie.blogspot.com/