Shortest algorithm to determine sub-triangle
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Fun (?) question here. Given an arbitrary point on the triangle pictured below, what is the "best" way to determine which of the 60 sub triangles it lies within? Suppose I have the coordinates for all sub-triangle vertices.
"Best" is from a programming POV, so my though is to just check if the point is above, below (or on), a given line... then repeat. So maybe you check if it's above or below the 2nd steepest of the 4 lines that intersect at the bottom left vertex - if it's above, check above/below line x, if it's below check above/below line y, etc.
With minimal thought put into the algorithm, I was able to determine the location in 7 steps (meaning above/below 7 different lines) for 16 of the sub-triangles, 6 steps for 32 of the sub-triangles, and 5 steps for 12 of the sub-triangles. I'm fairly certain that this is not optimal. When I say optimal, I'd really like to minimize the max, so the 7 step triangles bug me.
I think 6 steps for 56 of the triangles and 5 steps for 4 of the triangles is a lower bound on the length of the "optimal" solution, but I don't think is achievable.
Any thoughts at the optimal solution? My gut said to split the sub triangles as closely to evenly as possible in each step, but I'm not even sure that's true (or how to do that).
In case it helps, you can view the big triangle as 15 medium sized triangles (3 in each of the 3 corners, 6 in the middle). Each of those 15 medium sized triangles is subdivided into 4 small triangles.
Thanks!
geometry algorithms
 |Â
show 1 more comment
up vote
0
down vote
favorite
Fun (?) question here. Given an arbitrary point on the triangle pictured below, what is the "best" way to determine which of the 60 sub triangles it lies within? Suppose I have the coordinates for all sub-triangle vertices.
"Best" is from a programming POV, so my though is to just check if the point is above, below (or on), a given line... then repeat. So maybe you check if it's above or below the 2nd steepest of the 4 lines that intersect at the bottom left vertex - if it's above, check above/below line x, if it's below check above/below line y, etc.
With minimal thought put into the algorithm, I was able to determine the location in 7 steps (meaning above/below 7 different lines) for 16 of the sub-triangles, 6 steps for 32 of the sub-triangles, and 5 steps for 12 of the sub-triangles. I'm fairly certain that this is not optimal. When I say optimal, I'd really like to minimize the max, so the 7 step triangles bug me.
I think 6 steps for 56 of the triangles and 5 steps for 4 of the triangles is a lower bound on the length of the "optimal" solution, but I don't think is achievable.
Any thoughts at the optimal solution? My gut said to split the sub triangles as closely to evenly as possible in each step, but I'm not even sure that's true (or how to do that).
In case it helps, you can view the big triangle as 15 medium sized triangles (3 in each of the 3 corners, 6 in the middle). Each of those 15 medium sized triangles is subdivided into 4 small triangles.
Thanks!
geometry algorithms
1
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
2
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
2
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Fun (?) question here. Given an arbitrary point on the triangle pictured below, what is the "best" way to determine which of the 60 sub triangles it lies within? Suppose I have the coordinates for all sub-triangle vertices.
"Best" is from a programming POV, so my though is to just check if the point is above, below (or on), a given line... then repeat. So maybe you check if it's above or below the 2nd steepest of the 4 lines that intersect at the bottom left vertex - if it's above, check above/below line x, if it's below check above/below line y, etc.
With minimal thought put into the algorithm, I was able to determine the location in 7 steps (meaning above/below 7 different lines) for 16 of the sub-triangles, 6 steps for 32 of the sub-triangles, and 5 steps for 12 of the sub-triangles. I'm fairly certain that this is not optimal. When I say optimal, I'd really like to minimize the max, so the 7 step triangles bug me.
I think 6 steps for 56 of the triangles and 5 steps for 4 of the triangles is a lower bound on the length of the "optimal" solution, but I don't think is achievable.
Any thoughts at the optimal solution? My gut said to split the sub triangles as closely to evenly as possible in each step, but I'm not even sure that's true (or how to do that).
In case it helps, you can view the big triangle as 15 medium sized triangles (3 in each of the 3 corners, 6 in the middle). Each of those 15 medium sized triangles is subdivided into 4 small triangles.
Thanks!
geometry algorithms
Fun (?) question here. Given an arbitrary point on the triangle pictured below, what is the "best" way to determine which of the 60 sub triangles it lies within? Suppose I have the coordinates for all sub-triangle vertices.
"Best" is from a programming POV, so my though is to just check if the point is above, below (or on), a given line... then repeat. So maybe you check if it's above or below the 2nd steepest of the 4 lines that intersect at the bottom left vertex - if it's above, check above/below line x, if it's below check above/below line y, etc.
With minimal thought put into the algorithm, I was able to determine the location in 7 steps (meaning above/below 7 different lines) for 16 of the sub-triangles, 6 steps for 32 of the sub-triangles, and 5 steps for 12 of the sub-triangles. I'm fairly certain that this is not optimal. When I say optimal, I'd really like to minimize the max, so the 7 step triangles bug me.
I think 6 steps for 56 of the triangles and 5 steps for 4 of the triangles is a lower bound on the length of the "optimal" solution, but I don't think is achievable.
Any thoughts at the optimal solution? My gut said to split the sub triangles as closely to evenly as possible in each step, but I'm not even sure that's true (or how to do that).
In case it helps, you can view the big triangle as 15 medium sized triangles (3 in each of the 3 corners, 6 in the middle). Each of those 15 medium sized triangles is subdivided into 4 small triangles.
Thanks!
geometry algorithms
asked Aug 1 at 20:51
Brian
287
287
1
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
2
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
2
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52
 |Â
show 1 more comment
1
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
2
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
2
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52
1
1
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
2
2
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
2
2
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2869507%2fshortest-algorithm-to-determine-sub-triangle%23new-answer', 'question_page');
);
Post as a guest
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
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
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
1
Try posting this on Code Golf SE. Mathematics SE doesn't really provide 'algorithms' which you ask for.
– Shawn Li
Aug 1 at 20:53
I will, and thanks for the advice. However, I think the crux of the problem is mathematical in nature as I'm looking to exploit the symmetries of this triangle.
– Brian
Aug 1 at 21:05
2
It seems move like stack overflow or computerscience SE than code golf to me. Code golf is about writing programs in the fewest possible number of bits.
– saulspatz
Aug 1 at 21:28
My guess is that the answer depends on how the triangles are constructed. Do you have that information? Or is it just some random partition into 60 triangles?
– Andrei
Aug 1 at 23:04
2
@ShawnLi Please do not suggest users to go to any site you're unfamiliar of. We only allow programming challenge on our site, with some exceptions. Question about constructing an algorithm is not one of them.
– user202729
Aug 2 at 0:52