Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2013-02-22 04:25:33

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Moving Circles

Hi!

I stumbled upon a problem that I was not able to solve at school with help of my teachers.

Info:
There are 2 circles. Each has its own radius and speed.
Circle 1 is going from point A to point B. Circle 2 from C to D.
They travel in 2D space in any direction and can have the same start, end or both.

All of the above data is known.

Question:
When will center of circle 2 be inside circle 1 and when it will go out of circle 1, if it will even be inside? 
How long is it inside? ( exitTime - entryTime)

Programming language that I'll be using for a solution doesn't really matter ( C++ most likely, but C# is considered as another option).
Simulation is not an option.

I hope I made myself clear enough.

Regards!

If I misused any name in English I apologize and please correct me.

Last edited by SmellyMan (2013-02-22 04:28:56)

Offline

#2 2013-02-22 04:29:44

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Hi;

What are the speeds of the circles? What are the sizes of the circles? How big is the space they are moving in? What law governs their motion? There are many more questions.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2013-02-22 04:45:16

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

I need just basic equation how to calculate this.
You can take sample data any you like ( or I can make some up, I don't have any with known solution).
Their motion is linear (I hope used a correct phrase).

Offline

#4 2013-02-22 04:50:20

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Hi;

There is a method to find whether two circles overlap.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#5 2013-02-22 04:58:06

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Hi;

There is a method to find whether two circles overlap.

This is a friend of him speaking and I'll try make it as clear as possible.

Imagine you have two tanks that have different ranges of fire (we're trying to make a game tongue). These tanks will move in a linear path, the path can be just about anything you imagine. The radius of the circle can also be "random". These paths can intersect, go parellel or move away from each other. As pointed, the range and the size of the circle is also almost any various number.

Let's take an example:
The tanks intersect at a 45 degree angle towards each other in a 2d plane of a limited size (this size limit can be made up if you so desire).
Tank A:
Moves at 20 m/s.
Has a range of 50m.
Moves for 100m.


Tank B:
Moves at 50 m/s.
Has a range of 30m.
Moves for 200m.

Also, as you can imagine, they have a starting point and an ending point, so it's not always necessary they start in the corner of the plane. They can be at any given point in this limited area.

Now, we have to know for how long the tank A will be shooting at tank B and the other way around. Keep in mind that there can be as many units on the field, but we're using two as an example. What we basically want to know, how to calculate when and for how long the tank will shoot other units.

Hopefully I've made it clear, thank you for taking your time!

EDIT: So if you imagine, the center point of the tank A has to be in the radius of tank B in order for it to start shooting. And the center point of tank B has to be in the radius of A to do the same.

Last edited by SmellyMan (2013-02-22 05:00:54)

Offline

#6 2013-02-22 05:05:58

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

The positions of the tanks are known so they do not need to be calculated. What you require is when the circle overlap contains the center point of the other circle.

Last edited by bobbym (2013-02-22 05:06:15)


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#7 2013-02-22 05:06:17

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

The positions of the tanks are known so they do not need to be calculated. What you require is when the circle overlap contains trhe center point of the other circle.

Yes, exactly!
Thank you for responding.

Last edited by SmellyMan (2013-02-22 05:06:31)

Offline

#8 2013-02-22 05:07:00

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Hi;

I will work on it and see what I can get.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#9 2013-02-22 05:07:57

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Hi;

I will work on it and see what I can get.

Thank you very much, I feel kind of bad for abusing your time, but it is very much appreciated. Don't feel rushed in any way.

Thank you again.

Offline

#10 2013-02-22 05:29:20

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Do you have the equations of the circles that represent where the tank can fire or do you need it?

If you have these equations the problem is trivially solved, if you do not I will show you how to get them. After that you can program it very easily in C++.

Last edited by bobbym (2013-02-22 05:46:18)


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#11 2013-02-22 05:48:53

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Do you have the equations of the circles that represent where the tank can fire or do you need it?

If you have these equations the problem is trivially solved, if you do not I will show you how to get them. After that you can program it very easily in C++.

No, I do not have any equations of the circles, it is one of our bigger problems in the process.
Best regards.

Offline

#12 2013-02-22 05:52:07

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

You have the positions of the tanks in (x,y) coordinates, which you will call the centers of the circles? You have the firing radius?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#13 2013-02-22 05:55:59

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

You have the positions of the tanks in (x,y) coordinates, which you will call the centers of the circles? You have the firing radius?

Yes, that is right. I also have the firing radius.

Offline

#14 2013-02-22 06:03:29

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

The equation that gives you the circle which represents where a tank can fire is

( x0 , y0 ) is the ordered pair which is the tank position  and r is the firing radius.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#15 2013-02-22 06:08:12

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

The equation that gives you the circle which represents where a tank can fire is

( x0 , y0 ) is the ordered pair which is the tank position  and r is the firing radius.

If the x0 and y0 is the current position of the tank in a 2d plane, we basically substract the full length of the axis to get a pythagoras theorem?

Offline

#16 2013-02-22 06:18:12

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Hi;

It is not necessary to figure anything now. I just want you to understand visually in a cartesian geometry sort of way.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#17 2013-02-22 06:18:57

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Hi;

It is not necessary to figure anything now. I just want you to understand visually in a cartesian geometry sort of way.

Yes I've drawn it myself and I've come to understand it, it's not all that complicated. I appreciate the picture!

Offline

#18 2013-02-22 06:22:02

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

The position of the other tank, the victim, is within range of the first tank when its center is on the circle or inside it.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#19 2013-02-22 06:23:44

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

The position of the other tank, the victim, is within range of the first tank when its center is on the circle or inside it.

Yes, that is also correct.

Offline

#20 2013-02-22 06:29:03

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Okay, hold on while I try to get the answer.

Take the xy coordinates of the second tank's position and plug them into the first tanks equation for the circle. That will give you the answer you want.

Last edited by bobbym (2013-02-22 06:42:40)


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#21 2013-02-22 06:50:35

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Okay, hold on while I try to get the answer.

Take the xy coordinates of the second tank's position and plug them into the first tanks equation for the circle. That will give you the answer you want.

This means the formula would look like this:

P1 (x,y) - First tank center
P2 (q,w) - Second tank center

Last edited by SmellyMan (2013-02-22 06:54:44)

Offline

#22 2013-02-22 06:55:31

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

Hi;

Not exactly, I will provide an example that will make all of this clear. Please hold while I draw it up.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#23 2013-02-22 07:05:20

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

bobbym wrote:

Hi;

Not exactly, I will provide an example that will make all of this clear. Please hold while I draw it up.

I'm sorry for any grief I may have caused. I have one more question, but perhaps it'll be resolved when you draw it, so it'll be more clear to me.
Thank you for your time!

Offline

#24 2013-02-22 07:23:15

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Moving Circles

In the drawing below you are the red tank. You are located at (6,1). You have a firing radius of 5. The equation of the circle for your tank is:

There are three enemy tanks they are in blue.

Tank1 is at (10,5) to find out if he is in range you just plug into this inequality,

4^2 + 4^2 is not ≤ to 25 so that tank is out of range as the drawing shows.

Tank2 is at (6,6), plugging in,

0^2 + 5^2 is ≤ to 25 so that tank is in range.

Tank3 is at (9,0), plugging in,

3^3 +(-1)^2 is is ≤ 25 so that tank is in range too as the drawing shows.

Last edited by bobbym (2013-02-22 07:27:45)


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#25 2013-02-22 07:31:15

SmellyMan
Member
Registered: 2011-03-06
Posts: 63

Re: Moving Circles

Yes, thank you, I figured it'd work like this. Basically you're just comparing the distance between the tanks, and if it's equal or less than the radius, it means that the tank 1 will attack the others.

There is however a different problem we're facing now, we've tackled the problem of figuring if they're inside the zone or not, the problem is because the tanks are moving. They're not stationary as portrayed.

As said, they're moving from point A to point B in a 2d limited plane. Both of them have a certain speed and the problem is that we'd like to figure out for how long would the tanks be in the shooting range of each other.

Figuring out if they're parallel, crossing and the angle of crossing isn't a problem. What we're basically looking for, when will the shooting start and for how long will the tank 1 shoot tank 2. Again, they're moving at different speeds and they have different paths with different lengths.

Offline

Board footer

Powered by FluxBB