Random point within triangle + within 2 radiuses

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am working on pathfinding for a 2D game, and need to obtain a random point within a triangle. This is simple, I am just sampling 3 times from a uniformly distributed random variable, then blend the 3 coordinates to get my random point.
given 3 triangle coordinates (2D): $A$, $B$, $C$ I can get a random point like this: uniform random point in triangle
However, now I also have a constrain that my random point must be between minRadius and maxRadius from some external coordinate.
The triangle is guaranteed to have some or all of its area inside this range.
There are seven possible states:

Is there a simple way to get such a random coordinate? Clamping it to the circumference (if outside of the range) would be undesirable, as it would introduce a bias towards the circumferences
Edit:
Both radiuses are measured from the same coordinate
vectors random
add a comment |Â
up vote
0
down vote
favorite
I am working on pathfinding for a 2D game, and need to obtain a random point within a triangle. This is simple, I am just sampling 3 times from a uniformly distributed random variable, then blend the 3 coordinates to get my random point.
given 3 triangle coordinates (2D): $A$, $B$, $C$ I can get a random point like this: uniform random point in triangle
However, now I also have a constrain that my random point must be between minRadius and maxRadius from some external coordinate.
The triangle is guaranteed to have some or all of its area inside this range.
There are seven possible states:

Is there a simple way to get such a random coordinate? Clamping it to the circumference (if outside of the range) would be undesirable, as it would introduce a bias towards the circumferences
Edit:
Both radiuses are measured from the same coordinate
vectors random
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
2
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on pathfinding for a 2D game, and need to obtain a random point within a triangle. This is simple, I am just sampling 3 times from a uniformly distributed random variable, then blend the 3 coordinates to get my random point.
given 3 triangle coordinates (2D): $A$, $B$, $C$ I can get a random point like this: uniform random point in triangle
However, now I also have a constrain that my random point must be between minRadius and maxRadius from some external coordinate.
The triangle is guaranteed to have some or all of its area inside this range.
There are seven possible states:

Is there a simple way to get such a random coordinate? Clamping it to the circumference (if outside of the range) would be undesirable, as it would introduce a bias towards the circumferences
Edit:
Both radiuses are measured from the same coordinate
vectors random
I am working on pathfinding for a 2D game, and need to obtain a random point within a triangle. This is simple, I am just sampling 3 times from a uniformly distributed random variable, then blend the 3 coordinates to get my random point.
given 3 triangle coordinates (2D): $A$, $B$, $C$ I can get a random point like this: uniform random point in triangle
However, now I also have a constrain that my random point must be between minRadius and maxRadius from some external coordinate.
The triangle is guaranteed to have some or all of its area inside this range.
There are seven possible states:

Is there a simple way to get such a random coordinate? Clamping it to the circumference (if outside of the range) would be undesirable, as it would introduce a bias towards the circumferences
Edit:
Both radiuses are measured from the same coordinate
vectors random
edited Aug 17 at 23:12
asked Aug 17 at 22:35
Kari
1479
1479
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
2
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29
add a comment |Â
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
2
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
2
2
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29
add a 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%2f2886256%2frandom-point-within-triangle-within-2-radiuses%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
Could you be more specific how you choose points in the triangles?
â M. Nestor
Aug 17 at 23:07
I've edited my question, I am using this post's method: math.stackexchange.com/q/18686/147567
â Kari
Aug 17 at 23:13
2
By far, the easiest approach is to use the rejection method. Basically, you repeat the following process. Take a random point inside the triangle like you are currently doing, accept it is if it satisfies your other constraint, and reject it if it does not. Stop after you accept a point. The only downside to this method is that if you have a very small overlap between the annulus (your other constraint) and the triangle, then it may slow down your game. But I doubt that this will be an actual bottleneck in your code.
â sasquires
Aug 17 at 23:29