Get distance between two points including size of âentitiesâ.
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
--------------
| p1 |
| p2 |
--------------
The formula to work out the difference between these two elements could be written as:
distance = ((x1-x2)(x1-x2)+(y1-y2)(y1-y2))
-----------------------
| p1p1 |
| p1p1 |
| |
| p2 |
-----------------------
With the above problem though, how would you get the distance if one of the points also had a size? So if p2 was "covering" p1's bounding box then the distance would be 0, and if p2 was 5 to the left or right of p1's bounding box then distance would be 5.
Would someone please show and try to explain a formula for this problem?
Thanks in advance
calculus linear-algebra geometry
add a comment |Â
up vote
0
down vote
favorite
--------------
| p1 |
| p2 |
--------------
The formula to work out the difference between these two elements could be written as:
distance = ((x1-x2)(x1-x2)+(y1-y2)(y1-y2))
-----------------------
| p1p1 |
| p1p1 |
| |
| p2 |
-----------------------
With the above problem though, how would you get the distance if one of the points also had a size? So if p2 was "covering" p1's bounding box then the distance would be 0, and if p2 was 5 to the left or right of p1's bounding box then distance would be 5.
Would someone please show and try to explain a formula for this problem?
Thanks in advance
calculus linear-algebra geometry
1
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
--------------
| p1 |
| p2 |
--------------
The formula to work out the difference between these two elements could be written as:
distance = ((x1-x2)(x1-x2)+(y1-y2)(y1-y2))
-----------------------
| p1p1 |
| p1p1 |
| |
| p2 |
-----------------------
With the above problem though, how would you get the distance if one of the points also had a size? So if p2 was "covering" p1's bounding box then the distance would be 0, and if p2 was 5 to the left or right of p1's bounding box then distance would be 5.
Would someone please show and try to explain a formula for this problem?
Thanks in advance
calculus linear-algebra geometry
--------------
| p1 |
| p2 |
--------------
The formula to work out the difference between these two elements could be written as:
distance = ((x1-x2)(x1-x2)+(y1-y2)(y1-y2))
-----------------------
| p1p1 |
| p1p1 |
| |
| p2 |
-----------------------
With the above problem though, how would you get the distance if one of the points also had a size? So if p2 was "covering" p1's bounding box then the distance would be 0, and if p2 was 5 to the left or right of p1's bounding box then distance would be 5.
Would someone please show and try to explain a formula for this problem?
Thanks in advance
calculus linear-algebra geometry
calculus linear-algebra geometry
edited Sep 7 at 10:48
asked Sep 7 at 10:41
Zephni
1013
1013
1
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32
add a comment |Â
1
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32
1
1
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32
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%2f2908500%2fget-distance-between-two-points-including-size-of-entities%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
You can calculate the distance between the middle of the bounding box to the other point. Aside from that you have to take the square root of your formula in order to get the distance.
â EuklidAlexandria
Sep 7 at 11:13
@EuklidAlexandria ah! So I could just subtract half the size after finding the distance, and just make sure distance doesn't go below 0!
â Zephni
Sep 7 at 11:21
First of all you have to calculate the centre of the bounding box. Then you can calculate the distance from the centre to the other by point with the square root of your formula.
â EuklidAlexandria
Sep 7 at 11:32