Getting slice number of regular polygon from coordinates
up vote
0
down vote
favorite
For an n sided polygon divided up into n triangles, i want the triangle "index" from a coordinate inside the polygon
Example:
The coordinates at the green dot should give 2, the red dot should give 5 and the blue dot should give 3
Coordinate range is from 0 to diameter of the polygon
The polygon is not necessarily a 6 sided polygon
geometry polygons
add a comment |
up vote
0
down vote
favorite
For an n sided polygon divided up into n triangles, i want the triangle "index" from a coordinate inside the polygon
Example:
The coordinates at the green dot should give 2, the red dot should give 5 and the blue dot should give 3
Coordinate range is from 0 to diameter of the polygon
The polygon is not necessarily a 6 sided polygon
geometry polygons
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For an n sided polygon divided up into n triangles, i want the triangle "index" from a coordinate inside the polygon
Example:
The coordinates at the green dot should give 2, the red dot should give 5 and the blue dot should give 3
Coordinate range is from 0 to diameter of the polygon
The polygon is not necessarily a 6 sided polygon
geometry polygons
For an n sided polygon divided up into n triangles, i want the triangle "index" from a coordinate inside the polygon
Example:
The coordinates at the green dot should give 2, the red dot should give 5 and the blue dot should give 3
Coordinate range is from 0 to diameter of the polygon
The polygon is not necessarily a 6 sided polygon
geometry polygons
geometry polygons
edited Nov 11 at 14:44
asked Nov 11 at 13:46
nobbele
12
12
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32
add a comment |
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Solved it using this(C# code but can probably be converted into math equation)
float arctan = Mathf.Atan(originRelativePos.x / originRelativePos.y);
float sectorDec = arctan / ((2 * Mathf.PI) / sectorCount);
float max = sectorCount / 4;
sectorDec = originRelativePos.x < 0 ? -sectorDec : sectorDec;
sectorDec = sectorDec > 0 ? sectorDec : max * 2 + sectorDec + 1;
sectorDec = originRelativePos.x < 0 ? sectorCount - sectorDec : sectorDec;
int sector = (int)sectorDec;
sector is the number of the sector, originRelativePos is position relative to the origin
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Solved it using this(C# code but can probably be converted into math equation)
float arctan = Mathf.Atan(originRelativePos.x / originRelativePos.y);
float sectorDec = arctan / ((2 * Mathf.PI) / sectorCount);
float max = sectorCount / 4;
sectorDec = originRelativePos.x < 0 ? -sectorDec : sectorDec;
sectorDec = sectorDec > 0 ? sectorDec : max * 2 + sectorDec + 1;
sectorDec = originRelativePos.x < 0 ? sectorCount - sectorDec : sectorDec;
int sector = (int)sectorDec;
sector is the number of the sector, originRelativePos is position relative to the origin
add a comment |
up vote
0
down vote
accepted
Solved it using this(C# code but can probably be converted into math equation)
float arctan = Mathf.Atan(originRelativePos.x / originRelativePos.y);
float sectorDec = arctan / ((2 * Mathf.PI) / sectorCount);
float max = sectorCount / 4;
sectorDec = originRelativePos.x < 0 ? -sectorDec : sectorDec;
sectorDec = sectorDec > 0 ? sectorDec : max * 2 + sectorDec + 1;
sectorDec = originRelativePos.x < 0 ? sectorCount - sectorDec : sectorDec;
int sector = (int)sectorDec;
sector is the number of the sector, originRelativePos is position relative to the origin
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Solved it using this(C# code but can probably be converted into math equation)
float arctan = Mathf.Atan(originRelativePos.x / originRelativePos.y);
float sectorDec = arctan / ((2 * Mathf.PI) / sectorCount);
float max = sectorCount / 4;
sectorDec = originRelativePos.x < 0 ? -sectorDec : sectorDec;
sectorDec = sectorDec > 0 ? sectorDec : max * 2 + sectorDec + 1;
sectorDec = originRelativePos.x < 0 ? sectorCount - sectorDec : sectorDec;
int sector = (int)sectorDec;
sector is the number of the sector, originRelativePos is position relative to the origin
Solved it using this(C# code but can probably be converted into math equation)
float arctan = Mathf.Atan(originRelativePos.x / originRelativePos.y);
float sectorDec = arctan / ((2 * Mathf.PI) / sectorCount);
float max = sectorCount / 4;
sectorDec = originRelativePos.x < 0 ? -sectorDec : sectorDec;
sectorDec = sectorDec > 0 ? sectorDec : max * 2 + sectorDec + 1;
sectorDec = originRelativePos.x < 0 ? sectorCount - sectorDec : sectorDec;
int sector = (int)sectorDec;
sector is the number of the sector, originRelativePos is position relative to the origin
answered Nov 16 at 22:44
nobbele
12
12
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2993895%2fgetting-slice-number-of-regular-polygon-from-coordinates%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Do you have freedom of scaling, rotation and choosing the origin?
– Moti
Nov 11 at 16:27
only scaling/radius @Moti
– nobbele
Nov 16 at 18:34
What you mean by give? Being inside the numbered region?
– Moti
Nov 16 at 21:32