Jump to content
  • Advertisement
Sign in to follow this  
Semei

Somehow weird coordinate system, need help

This topic is 2535 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

y6zrm.png

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?

Share this post


Link to post
Share on other sites
Advertisement
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!

Share this post


Link to post
Share on other sites
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];
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!