Converting a point to a hexagon coordinate












0












$begingroup$


Here is a link to a graphing calculator to help you visualize what I'm talking about (I made it): https://www.desmos.com/calculator/ccxnopqqkr



Slide Hq and Hr to change the coordinates of the Red Hexagon (Axial coordinates, not Cartesian).



My question is, what formula would convert that black point (or any point in space) to the axial coordinates of the hexagon it falls into? Note, these are not for regular hexagons. If it falls directly on the border between two hexagons, I need it to consistently push (round) in the same direction every time, so that it I can be sure which hex a point will convert to.



The reason I need this is for a game I'm making (A simple board game). It's in an isometric view with a hexagon game grid. The reason the hexagon on that link is scaled down vertically is to match the hexagons in the game. It has the exact same coordinates (including the origin of the hexagon tile being the top-left).










share|cite|improve this question









$endgroup$












  • $begingroup$
    Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
    $endgroup$
    – amd
    Jan 2 at 5:05
















0












$begingroup$


Here is a link to a graphing calculator to help you visualize what I'm talking about (I made it): https://www.desmos.com/calculator/ccxnopqqkr



Slide Hq and Hr to change the coordinates of the Red Hexagon (Axial coordinates, not Cartesian).



My question is, what formula would convert that black point (or any point in space) to the axial coordinates of the hexagon it falls into? Note, these are not for regular hexagons. If it falls directly on the border between two hexagons, I need it to consistently push (round) in the same direction every time, so that it I can be sure which hex a point will convert to.



The reason I need this is for a game I'm making (A simple board game). It's in an isometric view with a hexagon game grid. The reason the hexagon on that link is scaled down vertically is to match the hexagons in the game. It has the exact same coordinates (including the origin of the hexagon tile being the top-left).










share|cite|improve this question









$endgroup$












  • $begingroup$
    Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
    $endgroup$
    – amd
    Jan 2 at 5:05














0












0








0


0



$begingroup$


Here is a link to a graphing calculator to help you visualize what I'm talking about (I made it): https://www.desmos.com/calculator/ccxnopqqkr



Slide Hq and Hr to change the coordinates of the Red Hexagon (Axial coordinates, not Cartesian).



My question is, what formula would convert that black point (or any point in space) to the axial coordinates of the hexagon it falls into? Note, these are not for regular hexagons. If it falls directly on the border between two hexagons, I need it to consistently push (round) in the same direction every time, so that it I can be sure which hex a point will convert to.



The reason I need this is for a game I'm making (A simple board game). It's in an isometric view with a hexagon game grid. The reason the hexagon on that link is scaled down vertically is to match the hexagons in the game. It has the exact same coordinates (including the origin of the hexagon tile being the top-left).










share|cite|improve this question









$endgroup$




Here is a link to a graphing calculator to help you visualize what I'm talking about (I made it): https://www.desmos.com/calculator/ccxnopqqkr



Slide Hq and Hr to change the coordinates of the Red Hexagon (Axial coordinates, not Cartesian).



My question is, what formula would convert that black point (or any point in space) to the axial coordinates of the hexagon it falls into? Note, these are not for regular hexagons. If it falls directly on the border between two hexagons, I need it to consistently push (round) in the same direction every time, so that it I can be sure which hex a point will convert to.



The reason I need this is for a game I'm making (A simple board game). It's in an isometric view with a hexagon game grid. The reason the hexagon on that link is scaled down vertically is to match the hexagons in the game. It has the exact same coordinates (including the origin of the hexagon tile being the top-left).







geometry






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Jan 1 at 17:00









user91670user91670

83




83












  • $begingroup$
    Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
    $endgroup$
    – amd
    Jan 2 at 5:05


















  • $begingroup$
    Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
    $endgroup$
    – amd
    Jan 2 at 5:05
















$begingroup$
Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
$endgroup$
– amd
Jan 2 at 5:05




$begingroup$
Scale to make the hexagons regular and then apply your favorite Cartesian-to-hex-coordinate mapping from the many written up on the Internet.
$endgroup$
– amd
Jan 2 at 5:05










1 Answer
1






active

oldest

votes


















1












$begingroup$

A formula will not be able to deal directly with the edge cases. To convert from $(X,Y)$ to $(H_q,H_r)$ you will need an algorithm. To begin with, imagine vertical lines draw through the top left points of the hexagons. This divides the grid into columns, and you need to know which column the point is in. This is simply $lfloorfrac{x}{18}rfloor$. We'll call this value $a$. We then divide that column into cells using the horizontal lines of the hexagons in that column so that each cell is an $18times14$ rectangle with its top left corner concurrent with that of a hexagon, then find a value $b$ for the cell containing the given point.



When $a$ is even we calculate $b=lfloorfrac{-y}{14}rfloor$, and when $a$ is odd $b=lfloorfrac{-y-7}{14}rfloor$.



Using these values we find $H_r=b-lfloorfrac{a}{2}rfloor$ and $H_q=H_r+a$. Also use these values to find the $(x,y)$ values for the top left corner $P$ of the cell.



When $a$ is even $P_{x,y}=(18a,-14b)$, when $a$ is odd $P_{x,y}=(18a,-14b-7)$.



Now check the location of the given point within the cell to see if it falls in one of the corner regions.



First let $T_x=X-P_x-11$. If this value $T_xle0$ then the point is in the main region and our values for $H_q$ and $H_r$ are correct. Otherwise, let $T_y=P_y-Y$.



Finally, if $T_y<7$ and $T_x>T_y$ we need subtract $1$ from $H_r$, or if $T_y>7$ and $T_x>14-T_y$ we need to add $1$ to $H_q$.



C code reference (tested and confirmed):



a=floor(x/18);
if(((int)a%2)==0){
b=floor(-y/14);
px=18*a;
py=-14*b;
}else{
b=floor((-y-7)/14);
px=18*a;
py=-14*b-7;
}
hr=b-floor(a/2);
hq=hr+a;
tx=x-px-11;
if(tx>0){
ty=py-y;
if((ty<7)&&(tx>ty))hr-=1;
if((ty>7)&&(tx>14-ty))hq+=1;
}





share|cite|improve this answer











$endgroup$













  • $begingroup$
    Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
    $endgroup$
    – user91670
    Jan 3 at 14:46










  • $begingroup$
    @user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:46










  • $begingroup$
    Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:54










  • $begingroup$
    @user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 22:08










  • $begingroup$
    The edit fixed all of the issues. Thank you very much!
    $endgroup$
    – user91670
    Jan 3 at 23:20











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3058657%2fconverting-a-point-to-a-hexagon-coordinate%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

A formula will not be able to deal directly with the edge cases. To convert from $(X,Y)$ to $(H_q,H_r)$ you will need an algorithm. To begin with, imagine vertical lines draw through the top left points of the hexagons. This divides the grid into columns, and you need to know which column the point is in. This is simply $lfloorfrac{x}{18}rfloor$. We'll call this value $a$. We then divide that column into cells using the horizontal lines of the hexagons in that column so that each cell is an $18times14$ rectangle with its top left corner concurrent with that of a hexagon, then find a value $b$ for the cell containing the given point.



When $a$ is even we calculate $b=lfloorfrac{-y}{14}rfloor$, and when $a$ is odd $b=lfloorfrac{-y-7}{14}rfloor$.



Using these values we find $H_r=b-lfloorfrac{a}{2}rfloor$ and $H_q=H_r+a$. Also use these values to find the $(x,y)$ values for the top left corner $P$ of the cell.



When $a$ is even $P_{x,y}=(18a,-14b)$, when $a$ is odd $P_{x,y}=(18a,-14b-7)$.



Now check the location of the given point within the cell to see if it falls in one of the corner regions.



First let $T_x=X-P_x-11$. If this value $T_xle0$ then the point is in the main region and our values for $H_q$ and $H_r$ are correct. Otherwise, let $T_y=P_y-Y$.



Finally, if $T_y<7$ and $T_x>T_y$ we need subtract $1$ from $H_r$, or if $T_y>7$ and $T_x>14-T_y$ we need to add $1$ to $H_q$.



C code reference (tested and confirmed):



a=floor(x/18);
if(((int)a%2)==0){
b=floor(-y/14);
px=18*a;
py=-14*b;
}else{
b=floor((-y-7)/14);
px=18*a;
py=-14*b-7;
}
hr=b-floor(a/2);
hq=hr+a;
tx=x-px-11;
if(tx>0){
ty=py-y;
if((ty<7)&&(tx>ty))hr-=1;
if((ty>7)&&(tx>14-ty))hq+=1;
}





share|cite|improve this answer











$endgroup$













  • $begingroup$
    Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
    $endgroup$
    – user91670
    Jan 3 at 14:46










  • $begingroup$
    @user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:46










  • $begingroup$
    Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:54










  • $begingroup$
    @user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 22:08










  • $begingroup$
    The edit fixed all of the issues. Thank you very much!
    $endgroup$
    – user91670
    Jan 3 at 23:20
















1












$begingroup$

A formula will not be able to deal directly with the edge cases. To convert from $(X,Y)$ to $(H_q,H_r)$ you will need an algorithm. To begin with, imagine vertical lines draw through the top left points of the hexagons. This divides the grid into columns, and you need to know which column the point is in. This is simply $lfloorfrac{x}{18}rfloor$. We'll call this value $a$. We then divide that column into cells using the horizontal lines of the hexagons in that column so that each cell is an $18times14$ rectangle with its top left corner concurrent with that of a hexagon, then find a value $b$ for the cell containing the given point.



When $a$ is even we calculate $b=lfloorfrac{-y}{14}rfloor$, and when $a$ is odd $b=lfloorfrac{-y-7}{14}rfloor$.



Using these values we find $H_r=b-lfloorfrac{a}{2}rfloor$ and $H_q=H_r+a$. Also use these values to find the $(x,y)$ values for the top left corner $P$ of the cell.



When $a$ is even $P_{x,y}=(18a,-14b)$, when $a$ is odd $P_{x,y}=(18a,-14b-7)$.



Now check the location of the given point within the cell to see if it falls in one of the corner regions.



First let $T_x=X-P_x-11$. If this value $T_xle0$ then the point is in the main region and our values for $H_q$ and $H_r$ are correct. Otherwise, let $T_y=P_y-Y$.



Finally, if $T_y<7$ and $T_x>T_y$ we need subtract $1$ from $H_r$, or if $T_y>7$ and $T_x>14-T_y$ we need to add $1$ to $H_q$.



C code reference (tested and confirmed):



a=floor(x/18);
if(((int)a%2)==0){
b=floor(-y/14);
px=18*a;
py=-14*b;
}else{
b=floor((-y-7)/14);
px=18*a;
py=-14*b-7;
}
hr=b-floor(a/2);
hq=hr+a;
tx=x-px-11;
if(tx>0){
ty=py-y;
if((ty<7)&&(tx>ty))hr-=1;
if((ty>7)&&(tx>14-ty))hq+=1;
}





share|cite|improve this answer











$endgroup$













  • $begingroup$
    Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
    $endgroup$
    – user91670
    Jan 3 at 14:46










  • $begingroup$
    @user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:46










  • $begingroup$
    Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:54










  • $begingroup$
    @user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 22:08










  • $begingroup$
    The edit fixed all of the issues. Thank you very much!
    $endgroup$
    – user91670
    Jan 3 at 23:20














1












1








1





$begingroup$

A formula will not be able to deal directly with the edge cases. To convert from $(X,Y)$ to $(H_q,H_r)$ you will need an algorithm. To begin with, imagine vertical lines draw through the top left points of the hexagons. This divides the grid into columns, and you need to know which column the point is in. This is simply $lfloorfrac{x}{18}rfloor$. We'll call this value $a$. We then divide that column into cells using the horizontal lines of the hexagons in that column so that each cell is an $18times14$ rectangle with its top left corner concurrent with that of a hexagon, then find a value $b$ for the cell containing the given point.



When $a$ is even we calculate $b=lfloorfrac{-y}{14}rfloor$, and when $a$ is odd $b=lfloorfrac{-y-7}{14}rfloor$.



Using these values we find $H_r=b-lfloorfrac{a}{2}rfloor$ and $H_q=H_r+a$. Also use these values to find the $(x,y)$ values for the top left corner $P$ of the cell.



When $a$ is even $P_{x,y}=(18a,-14b)$, when $a$ is odd $P_{x,y}=(18a,-14b-7)$.



Now check the location of the given point within the cell to see if it falls in one of the corner regions.



First let $T_x=X-P_x-11$. If this value $T_xle0$ then the point is in the main region and our values for $H_q$ and $H_r$ are correct. Otherwise, let $T_y=P_y-Y$.



Finally, if $T_y<7$ and $T_x>T_y$ we need subtract $1$ from $H_r$, or if $T_y>7$ and $T_x>14-T_y$ we need to add $1$ to $H_q$.



C code reference (tested and confirmed):



a=floor(x/18);
if(((int)a%2)==0){
b=floor(-y/14);
px=18*a;
py=-14*b;
}else{
b=floor((-y-7)/14);
px=18*a;
py=-14*b-7;
}
hr=b-floor(a/2);
hq=hr+a;
tx=x-px-11;
if(tx>0){
ty=py-y;
if((ty<7)&&(tx>ty))hr-=1;
if((ty>7)&&(tx>14-ty))hq+=1;
}





share|cite|improve this answer











$endgroup$



A formula will not be able to deal directly with the edge cases. To convert from $(X,Y)$ to $(H_q,H_r)$ you will need an algorithm. To begin with, imagine vertical lines draw through the top left points of the hexagons. This divides the grid into columns, and you need to know which column the point is in. This is simply $lfloorfrac{x}{18}rfloor$. We'll call this value $a$. We then divide that column into cells using the horizontal lines of the hexagons in that column so that each cell is an $18times14$ rectangle with its top left corner concurrent with that of a hexagon, then find a value $b$ for the cell containing the given point.



When $a$ is even we calculate $b=lfloorfrac{-y}{14}rfloor$, and when $a$ is odd $b=lfloorfrac{-y-7}{14}rfloor$.



Using these values we find $H_r=b-lfloorfrac{a}{2}rfloor$ and $H_q=H_r+a$. Also use these values to find the $(x,y)$ values for the top left corner $P$ of the cell.



When $a$ is even $P_{x,y}=(18a,-14b)$, when $a$ is odd $P_{x,y}=(18a,-14b-7)$.



Now check the location of the given point within the cell to see if it falls in one of the corner regions.



First let $T_x=X-P_x-11$. If this value $T_xle0$ then the point is in the main region and our values for $H_q$ and $H_r$ are correct. Otherwise, let $T_y=P_y-Y$.



Finally, if $T_y<7$ and $T_x>T_y$ we need subtract $1$ from $H_r$, or if $T_y>7$ and $T_x>14-T_y$ we need to add $1$ to $H_q$.



C code reference (tested and confirmed):



a=floor(x/18);
if(((int)a%2)==0){
b=floor(-y/14);
px=18*a;
py=-14*b;
}else{
b=floor((-y-7)/14);
px=18*a;
py=-14*b-7;
}
hr=b-floor(a/2);
hq=hr+a;
tx=x-px-11;
if(tx>0){
ty=py-y;
if((ty<7)&&(tx>ty))hr-=1;
if((ty>7)&&(tx>14-ty))hq+=1;
}






share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Jan 3 at 22:04

























answered Jan 2 at 13:13









Daniel MathiasDaniel Mathias

1,33018




1,33018












  • $begingroup$
    Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
    $endgroup$
    – user91670
    Jan 3 at 14:46










  • $begingroup$
    @user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:46










  • $begingroup$
    Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:54










  • $begingroup$
    @user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 22:08










  • $begingroup$
    The edit fixed all of the issues. Thank you very much!
    $endgroup$
    – user91670
    Jan 3 at 23:20


















  • $begingroup$
    Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
    $endgroup$
    – user91670
    Jan 3 at 14:46










  • $begingroup$
    @user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:46










  • $begingroup$
    Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
    $endgroup$
    – Daniel Mathias
    Jan 3 at 16:54










  • $begingroup$
    @user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
    $endgroup$
    – Daniel Mathias
    Jan 3 at 22:08










  • $begingroup$
    The edit fixed all of the issues. Thank you very much!
    $endgroup$
    – user91670
    Jan 3 at 23:20
















$begingroup$
Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
$endgroup$
– user91670
Jan 3 at 14:46




$begingroup$
Hi, I tried implementing that as an algorithm but it seems to return the wrong result. I set my mouse coordinates to (-16,-41) (My map is offset to position (64,64) so this is correctly on-screen, but that shouldn't matter as I subtract 64 from the mouse's x and y positions). At (-16,-41) for X,Y, it returns an Hq of 1 and an Hr of 2, when the expected values should be Hq = 2 and Hr = 3.
$endgroup$
– user91670
Jan 3 at 14:46












$begingroup$
@user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
$endgroup$
– Daniel Mathias
Jan 3 at 16:46




$begingroup$
@user91670 After further inspection, I have edited the answer to correct two errors. For odd $a$, $b=lfloorfrac{-y-7}{14}rfloor$ and for all $a$, $H_r=b-lfloorfrac{a}{2}rfloor$.
$endgroup$
– Daniel Mathias
Jan 3 at 16:46












$begingroup$
Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
$endgroup$
– Daniel Mathias
Jan 3 at 16:54




$begingroup$
Similar correction for $P_y$ when $a$ is odd: $P_y=-14b-7$
$endgroup$
– Daniel Mathias
Jan 3 at 16:54












$begingroup$
@user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
$endgroup$
– Daniel Mathias
Jan 3 at 22:08




$begingroup$
@user91670 My apologies for not writing and testing code in the first place. The previously mentioned changes have been made, as well as the condition $T_x>T_y$ when $T_y<7$. See changes in post.
$endgroup$
– Daniel Mathias
Jan 3 at 22:08












$begingroup$
The edit fixed all of the issues. Thank you very much!
$endgroup$
– user91670
Jan 3 at 23:20




$begingroup$
The edit fixed all of the issues. Thank you very much!
$endgroup$
– user91670
Jan 3 at 23:20


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3058657%2fconverting-a-point-to-a-hexagon-coordinate%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Cabo Verde

Gyllenstierna