• This forum is strictly intended to be used by members of the VS Battles wiki. Please only register if you have an autoconfirmed account there, as otherwise your registration will be rejected. If you have already registered once, do not do so again, and contact Antvasima if you encounter any problems.

    For instructions regarding the exact procedure to sign up to this forum, please click here.
  • We need Patreon donations for this forum to have all of its running costs financially secured.

    Community members who help us out will receive badges that give them several different benefits, including the removal of all advertisements in this forum, but donations from non-members are also extremely appreciated.

    Please click here for further information, or here to directly visit our Patreon donations page.
  • Please click here for information about a large petition to help children in need.

Distance between two objects

Status
Not open for further replies.

Floxy178

He/Him
VS Battles
Calculation Group
Messages
1,024
Reaction score
1,092
Normally to find distance between 2 objects following method is used:

1. Angsizing both objects
2. Finding positive difference between them
3. Drawing a direct line between them and finding its length while taking closest object as a reference
4. Applying Pythagoras theorem

However this is a little flawed in reasoning and gives slightly lower results than it should. I'll try to provide a better method.

Here are all steps in visual.

Firstly, draw a line between objects on the panel. Line in Picture 2 is if we use closest object(red point) as a reference. If we use far one(blue point) we'll get second line in Picture 3.

Both of them look the same from the POV (like the line we drew at the start) but are different depending on what object you're using for reference.

Let's mark them as a and b accordingly. d1 will be distance to closest object and d2 will be distance to the other one. (look at Picture 4)

To use Pythagoras, we'll need a line perpendicular to a and b (Picture 5). After drawing a perpendicular H line from one side of the a line, it will divide b as (b+a)/2 and (b-a)/2.

As you see from the picture, needed distance x (red line) can be found as:

x = √(H^2 + (b+a)^2/4)

And since
H^2 = (d2-d1)^2 - (b-a)^2/4;

Formula will be:
x = √((d2-d1)^2 - (b-a)^2/4 + (b+a)^2/4)

Which can also be simplified to:
x = √((d2-d1)^2 + a*b)



Note:

I've also seen people visualizing angsize like that rather than like this. If that's the case, it should be done this way and formula will be:

x = √((d2-d1)^2 + (b+a)^2/4)

Agree: @DontTalkDT @Flashlight237

Disagree:
 
Last edited:
@DontTalkDT Adding this to your list of ideas to consider for calc shit.
 
After drawing a perpendicular H line from one side of the a line, it will divide b as (b+a)/2 and (b-a)/2.
Why? That doesn't sound correct to me. Take the case of a and b orthogonal to (the extended) d1 line for instance. In that case H (drawn on the same side as in the picture) would not divide b. Or, specifically, H would just run on the line labeled "d2-d1" and the part labeled "b-a/2" would have length 0. But for that we would need b = a, which doesn't need to be the case.
Or am I missing something? Could be.
jfRt1Gp.png



Given, this is calculable. Personally, I would start with the intercept theorem.
2560px-Intercept_theorem_a.svg.png
If we say S is the point of view, A is the close object and D is the far object, then we assume to know the distances of the sides SA, SD, AC and BD.
By the above theorem we have |SC|/|SD| = |AC| / |BD|, which is equivalent to |SC| = |AC| * |SD| / |BD|.
So we know all side lengths of the triangle with corners S A C now. Law of cosines gives us for the angle alpha (opposite to side AC):
alpha = arccos( |SA|^2 + |SC|^2 - |AC|^2 / (2 * |SA| * |SC|) )
and by setting our definition for |SC| we get
alpha = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2 / (2 * |SA| * |AC| * |SD| / |BD| ) ) = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC| / (2 * |SA| * |SD| / |BD| ) ) .
With that we know two sides and an angle of the triangle with corners S A and D. We want to calculate the length of AD.
Using low of cosines again we get
|AD|^2 = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * cos(alpha) = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC| / (2 * |SA| / |BD| * |SD| ) )
= |SA|^2 + |SD|^2 - 2 * |SA|^3 * |SD| + 2 * |SA| * |AC|^2 * |SD|^3 / |BD|^2 - |AC| * |BD|
Taking square root
|AD| = sqrt( |SA|^2 + |SD|^2 - 2 * |SA|^3 * |SD| + 2 * |SA| * |AC|^2 * |SD|^3 / |BD|^2 - |AC| * |BD| )
 
Why? That doesn't sound correct to me. Take the case of a and b orthogonal to (the extended) d1 line for instance. In that case H (drawn on the same side as in the picture) would not divide b. Or, specifically, H would just run on the line labeled "d2-d1" and the part labeled "b-a/2" would have length 0. But for that we would need b = a, which doesn't need to be the case.
Or am I missing something? Could be.
Because this isn't the case here. It should've looked like this. Because a and b can't represent depth. When I measure line a while taking reference from closest object it's like this line is drawn in a 2D plane same distance away as reference object. In your example those lines come closer or go forther from the POV which isn't the case.

So a and b won't have a random angle betweed d1 and d2. From perspective of POV we shoul look like this as that's the direction.

For example if I simply measured this line from person on the left, would you except that to look like this, or this?
 
alpha = arccos( |SA|^2 + |SC|^2 - |AC|^2 / (2 * |SA| * |SC|) )
Shouldn't it be:
alpha = arccos( (|SA|^2 + |SC|^2 - |AC|^2) / (2 * |SA| * |SC|) )
and by setting our definition for |SC| we get
alpha = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2 / (2 * |SA| * |AC| * |SD| / |BD| ) ) = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC| / (2 * |SA| * |SD| / |BD| ) ) .
alpha = arccos( (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) / (2 * |SA| * |AC| * |SD| / |BD| ) )

So it won't simplify those |AC| s.

Btw obviously I'm fine with this after corrections but what are we looking for is already a special case that can be found in easier way and we'll end up with same thing if I'm not mistaken. There's no need to use formula that would fit every case.
 
Why? That doesn't sound correct to me. Take the case of a and b orthogonal to (the extended) d1 line for instance. In that case H (drawn on the same side as in the picture) would not divide b. Or, specifically, H would just run on the line labeled "d2-d1" and the part labeled "b-a/2" would have length 0. But for that we would need b = a, which doesn't need to be the case.
Or am I missing something? Could be.
jfRt1Gp.png



Given, this is calculable. Personally, I would start with the intercept theorem.
2560px-Intercept_theorem_a.svg.png
If we say S is the point of view, A is the close object and D is the far object, then we assume to know the distances of the sides SA, SD, AC and BD.
By the above theorem we have |SC|/|SD| = |AC| / |BD|, which is equivalent to |SC| = |AC| * |SD| / |BD|.
So we know all side lengths of the triangle with corners S A C now. Law of cosines gives us for the angle alpha (opposite to side AC):
alpha = arccos( |SA|^2 + |SC|^2 - |AC|^2 / (2 * |SA| * |SC|) )
and by setting our definition for |SC| we get
alpha = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2 / (2 * |SA| * |AC| * |SD| / |BD| ) ) = arccos( |SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC| / (2 * |SA| * |SD| / |BD| ) ) .
With that we know two sides and an angle of the triangle with corners S A and D. We want to calculate the length of AD.
Using low of cosines again we get
|AD|^2 = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * cos(alpha) = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC| / (2 * |SA| / |BD| * |SD| ) )
= |SA|^2 + |SD|^2 - 2 * |SA|^3 * |SD| + 2 * |SA| * |AC|^2 * |SD|^3 / |BD|^2 - |AC| * |BD|
Taking square root
|AD| = sqrt( |SA|^2 + |SD|^2 - 2 * |SA|^3 * |SD| + 2 * |SA| * |AC|^2 * |SD|^3 / |BD|^2 - |AC| * |BD| )
Seems kinda like what they're trying to propose, but the way it's written here seems to explain it better.
 
|AD|^2 = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * cos(alpha) =

|SA|^2 + |SD|^2 - 2 * |SA| * |SD| * (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) / (2 * |SA| * |AC| * |SD| / |BD| ) =

|SA|^2 + |SD|^2 - (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) / (|AC| / |BD| ) =

|SA|^2 + |SD|^2 - (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) * |BD| / |AC|

Then we'll just take square root.

 
Last edited:
Seems kinda like what they're trying to propose, but the way it's written here seems to explain it better.
Yeah it's more universal and covers all cases. But if we agree on this:
a and b won't have a random angle betweed d1 and d2. From perspective of POV we shoul look like this as that's the direction.
Then there'll be no need for such a thing. As both formula in the OP and this:
|AD|^2 = |SA|^2 + |SD|^2 - 2 * |SA| * |SD| * cos(alpha) =

|SA|^2 + |SD|^2 - 2 * |SA| * |SD| * (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) / (2 * |SA| * |AC| * |SD| / |BD| ) =

|SA|^2 + |SD|^2 - (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) / (|AC| / |BD| ) =

|SA|^2 + |SD|^2 - (|SA|^2 + (|AC| * |SD| / |BD| )^2 - |AC|^2) * |BD| / |AC|

Then we'll just take square root.


Will give us the same result.
 
I'll show via example. Here are values that we need.

This formula gives ~487.33 cm
x = √((d2-d1)^2 - (b-a)^2/4 + (b+a)^2/4)
And this one gives ~487.65 cm (little difference is probably because of rounding)

The reason is that object that's x times further away from the POV will have x times more cm/px value. And so darawn line's length will also be proportional to this.

This means d2/d1 = b/a (d2 is |SD| and d1 is |SA|)

But by theorem we also have |SD|/|SC| = b/a

That's why |SA| and |SC| will be equal, so DT's first picture isn't possible due to reasoning that we use in angular sizing.
 
Because this isn't the case here. It should've looked like this. Because a and b can't represent depth. When I measure line a while taking reference from closest object it's like this line is drawn in a 2D plane same distance away as reference object. In your example those lines come closer or go forther from the POV which isn't the case.

So a and b won't have a random angle betweed d1 and d2. From perspective of POV we shoul look like this as that's the direction.

For example if I simply measured this line from person on the left, would you except that to look like this, or this?
I will comment on that and the other stuff after work (if I find the time), but it would be good if you answered my initial question before that.
Why would H specifically divide b as (b+a)/2 and (b-a)/2 in the first place?
 
I will comment on that and the other stuff after work (if I find the time), but it would be good if you answered my initial question before that.
Why would H specifically divide b as (b+a)/2 and (b-a)/2 in the first place?
Because ABDC should be a trapezium with equal lateral sides.
 
Shouldn't it be:
alpha = arccos( (|SA|^2 + |SC|^2 - |AC|^2) / (2 * |SA| * |SC|) )
Ah, yeah, misplaced a bracket.

Because ABDC should be a trapezium with equal lateral sides.

Ah, I see. The assumption is that the angles are the same. Yeah, in that case this should work as long as the line is drawn well.
 
Ah, I see. The assumption is that the angles are the same. Yeah, in that case this should work as long as the line is drawn well.
Thank you for your input 🙏

Btw are you agreeing with proposal in general or this was just a specific question?
 
Btw I forgot to write this in the OP earlier:
Which can also be simplified to:
x = √((d2-d1)^2 + a*b)
I think this one is more comfortable to use.

We'll get it using DT's method too, considering the fact that b/a equals to d2/d1 which will simplify that formula even more ending up with the same thing. (I checked using it in several examples and it works)
 
Last edited:
@DontTalkDT Adding this to your list of ideas to consider for calc shit.
@Mr. Bambu since you're online atm could you please tag DT to see if he agrees with latest version? 🙏
Btw I forgot to write this in the OP earlier:

I think this one is more comfortable to use.

We'll get it using DT's method too, considering the fact that b/a equals to d2/d1 which will simplify that formula even more ending up with the same thing. (I checked using it in several examples and it works)
 
Ah, yeah, misplaced a bracket.


Ah, I see. The assumption is that the angles are the same. Yeah, in that case this should work as long as the line is drawn well.
Thank you for your input 🙏

Btw are you agreeing with proposal in general or this was just a specific question?
@DontTalkDT Floxy has an outstanding question about whether or not you agree.
 
@Flashlight237 @Mr. Bambu Seems like you two were interested in DontTalk's thoughts. Now that he's accepted it, what do you think?
(I was interested in getting this resolved, or at least looked at; I don't have much in the way of valuable input, if I am pressed to give it)
 
(I was interested in getting this resolved, or at least looked at; I don't have much in the way of valuable input, if I am pressed to give it)
Then can you please tag someone who you believe can evaluate this? 🙏

DT is very reliable but idk if his vote counts or not.

If it requires at least 2 CGM approvals we'll need an extra vote minimum. I've already sent the thread in DMs of many CGMs myself.
 
DT seems to generally count as a CGM for this sorta thing, weirdly enough.
 
If no-one complains about that outcome in the next day or so, sure.
 
If no-one complains about that outcome in the next day or so, sure.
A week has passed since DT and Flashlight accepted the proposal, I doubt anyone will complain about this at this point.
 
Yeah, then this is accepted.
 
I think it'd fit here.
 
Would you feel comfortable adding that yourself if I unlocked the page?
 
Would you feel comfortable adding that yourself if I unlocked the page?
It's fine by me. Here's what I'm going to add btw.
Additional Angular Application:

You can also use this angsizing method to find the distance between two objects shown in the panel, if you happen to know or can estimate the size of the two objects properly. Simply:

1. Angsize the distance between the point of view and each of the objects.
2. Find the positive difference between the two values.
3. Draw a straight line between the points you want to find the distance between.
4. Calculate its length from nearby object and call it a.
5. Calculate its length from distant object and call it b.

Formula: distance between two objects = √((angsize difference)^2 + a*b)
 
Unlocked it.
 
Anything else left to do here? Everything seems to be applied.
 
Alright, locking it.
 
Status
Not open for further replies.
Back
Top