Jump to content

  • Log In with Google      Sign In   
  • Create Account

Somehow weird coordinate system, need help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

Posted 05 August 2011 - 07:05 PM

Hi, given this type of coordinate system (image) i need a way to get 3 vertex point coordinates (integer, red dots in image: bottom left point being 0, 0 and top right 3, 3) given a triangle coordinate.

Posted Image

Basically there are 2x number of elements in X row and they are arranged in triangle patern seen. I have a way made to do this, but its kinda ugly and im wondering if there is some other way to look at this and calculate coordinates without using conditionals?

Sponsor:

#2 Azh321   Members   -  Reputation: 569

Like
0Likes
Like

Posted 05 August 2011 - 08:58 PM

Looks interesting. Just something cool that I noticed, if you add the X and the Y values together, if the resulting value is even then the triangle is pointing up like /\ or if the resulting value is odd then the triangle is pointing down like \/
Nifty!

#3 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

Posted 06 August 2011 - 09:39 PM

Yep, that was the first thing i noticed.

I think i made universal approach by noticing that there is actually 3 types of points if we ignore Y coordinate: left, mid(tip), and top
and made a simple snipped to calculate points like this (mid x coordinate need some work thro):
(Does not work yet i think..)
public void CalculateTriPoints(int triX, int triY)
{
	int quadX = triX / 2;
	int quadY = triY;

	int facing = (triX + triY) % 2;

	var pointMID = quadPoints[quadX + (facing - quadY % 2) * (facing - quadY % 2), quadY + (1 - facing)];

	var pointLEFT = quadPoints[quadX, quadY + facing];
	var pointRIGHT = quadPoints[quadX + 1, quadY + facing];
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS