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

You are not logged in.

#1 Re: Coder's Corner » Moving Circles » 2013-02-22 08:45:45

bobbym wrote:

Hi;

I will work on it and see what can be done. I will post back here if I get anything.

Thank you for your time. If there is anything I can do to repay you in some way, I'll try my best to do so!

#2 Re: Coder's Corner » Moving Circles » 2013-02-22 08:23:24

bobbym wrote:

When you say how long would you be satisfied with n seconds or do you want an answer like 39 seconds?

n seconds is understandable to me. Basically it's just a matter of figuring out basing on the information we have (radius of the tank shooting range, his movement speed, path length and the direction of his path).
The entry point of when the tank starts shooting is also necessary in this case for us to be able to calculate any more information.

#3 Re: Coder's Corner » Moving Circles » 2013-02-22 08:14:21

bobbym wrote:

What do you want to do with that? What question are you asking?

I'm asking when and at what point will one tank start shooting other units. I'm also asking for how long that tank will shoot that unit.

Basically, the starting point of when Tank1 will shoot Tank2, and the ending point of when Tank1 will stop shooting Tank2.

#4 Re: Coder's Corner » Moving Circles » 2013-02-22 07:57:44

bobbym wrote:

Hi;

You are explaining it fine and this time you are supplying some numbers. Some constraints on the problem that mean simpler formulas rather than dozens of equations with hundreds of variables, none of which we know.

Okay, my question now is what do want to know exactly?

We know the exact position of the tanks, their exact radius, their movement speed, as well as the full length of their paths, as well as their starting and ending points.

#5 Re: Coder's Corner » Moving Circles » 2013-02-22 07:46:32

bobbym wrote:

Remember it is the radius squared.

The problem you are now describing is like asking how many cakes can I bake with some eggs. You do not know how many eggs per cake it takes and you do not know how many total eggs you have. The question is incomplete. I need much more information otherwise any answer is possible.

Pardon my ignorance, I thought I've explained it well before, but I guess I haven't.

This game is a turned based strategy sort of, each side has different units. The combat works in a round way. Basically you input your commands, and when the round is over they start moving. In the process of moving to a different point means that a tank will encounter a different tank. If it's in radius, as we calculated, he'll start shooting.

This plane is limited in a 2d space (let's says 1000m by 1000m). A tank has a certain radius of shooting (let's say 20m) and a speed of 100m/s.
Let's pretend I command my tank to move from a point P(100m,100m) to a point P1(100m,500m), meaning he'll travel 400m, taking him 4 seconds to reach that destination. He has a radius of 20m, and if he meets and enemy on that path in those 4 seconds, he'll start shooting at him.

A tank2 is moving from a point P2(200m,500) to a P3(100m,500m) in this example. He has a radius of 50m, meaning he is able to shoot targets that are 50m away from him. He also has a speed of 100m/s. He'll meet the tank1 on his path, and they'll engage in combat, but due to his bigger radius, it means he'll shoot him for longer as he's moving than the tank 1.

Now, I don't know how to approach this problem and see WHEN will tank1 start shooting other units based on his path and his movement speed, and the other problem how long will they stay intersected.
Figuring out the relative speed in this case also wouldn't be a problem, meaning I should be able to deduct for how long their paths would intervene. But as said, the radius is what throws me off, as one tank can have a bigger radius than the other one.

If I wasn't clear enough, I can draw a picture to show you what exactly I mean by that.

#6 Re: Coder's Corner » Moving Circles » 2013-02-22 07:31:15

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.

#7 Re: Coder's Corner » Moving Circles » 2013-02-22 07:05:20

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!

#8 Re: Coder's Corner » Moving Circles » 2013-02-22 06:50:35

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

#9 Re: Coder's Corner » Moving Circles » 2013-02-22 06:23:44

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.

#10 Re: Coder's Corner » Moving Circles » 2013-02-22 06:18:57

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!

#11 Re: Coder's Corner » Moving Circles » 2013-02-22 06:08:12

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?

#12 Re: Coder's Corner » Moving Circles » 2013-02-22 05:55:59

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.

#13 Re: Coder's Corner » Moving Circles » 2013-02-22 05:48:53

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.

#14 Re: Coder's Corner » Moving Circles » 2013-02-22 05:07:57

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.

#15 Re: Coder's Corner » Moving Circles » 2013-02-22 05:06:17

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.

#16 Re: Coder's Corner » Moving Circles » 2013-02-22 04:58:06

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.

#17 Re: Coder's Corner » Moving Circles » 2013-02-22 04:45:16

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).

#18 Coder's Corner » Moving Circles » 2013-02-22 04:25:33

SmellyMan
Replies: 35

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.

#19 Re: Help Me ! » Polynoms and it's mishaps. » 2012-01-18 03:45:03

bobbym wrote:

Hi;

Yes, that is correct!. This is called equating coefficients. You always match up the coefficients of like powers.

Thank you Bobby, I appreciate all the help you've given me!

And if my teacher would use this simple sentences maybe I'd understand it the first time she said it tongue. Well, if I learn, it's worth it!

Thanks again, you've helped me out a bunch!

#20 Re: Help Me ! » Polynoms and it's mishaps. » 2012-01-16 04:18:26

bobbym wrote:

Hi;

Wouldn't it be correct if it were 3a-2a=1

The 3a is a coefficient of x and the -2a is a coefficient of x^0, you can not combine them.

I see.

So for example if I had

3x^2+5ax+3x+2 and

x^2+2x+1


It would be 5a+3 = 2 ?

Using this as an example.

#21 Re: Help Me ! » Polynoms and it's mishaps. » 2012-01-16 02:45:59

Thanks for replying.

3x²-2x+3ax-2a = 3x²+x+b

Also, another question, you pointed out that I should just take the coefficient's.

And you wrote 3a-2=1

Wouldn't it be correct if it were 3a-2a=1 ?


And thanks for the 'tip'. I guess I haven't been paying attention to such details at the moment of solving. Will keep that in mind for later!

Thanks a bunch!

#22 Help Me ! » Polynoms and it's mishaps. » 2012-01-15 10:03:56

SmellyMan
Replies: 8

I was doing some exercises and I stumbled upon this problem:

For which numbers a and b is this correct:

(x+a)(3x-2) = 3x²+x+b

So I try to get rid of everything I don't need.

3x²-2x+3ax-2a = 3x²+x+b

So, if I want the polynoms to be correct I have to get coefficient and the base number to be the same.

-2x+3ax = x
and
b=-2a

-2x+3ax = x
-2x-x = -3ax /divide by x

-2-1 = -3a and it comes to a = 1.

I put a in the base and I get b = -2



Am I doing this correctly? And I'd also love a correction if I did something wrong.

Regards!

#23 Re: Help Me ! » In need of a throughout explanation of the following problem: » 2011-10-18 08:39:47

bobbym wrote:

I wish I could say that was true for me. Most of the bad programming I put in myself.

You seem okay to me. If you recognize what is bad then you are already on your way to fixing it.

We learn from our mistakes, we can usually consider something bad as 'I don't like it.'

But that's only if you're objective, the truth is, in this world, you have to be realllyy careful at what you're doing, how you're acting.

It's like every move you make, it counts.
That's why I try to do my best, and try to enjoy and relax at the same time!

That's why sleeping for me is quite important! So I'm off.

Thank you for the chatter, and thank you for explaining the problems to me.

Goodnight or enjoy the rest of your day! smile

#24 Re: Help Me ! » In need of a throughout explanation of the following problem: » 2011-10-18 08:25:16

bobbym wrote:

I am just the same. Which I guess means everyhting seems okay. That can change quickly.

Yes, I had a father and a mother and a religious upbringing. They taught me, morals, a code of conduct. It took a long time to sink in. Without it I would not be here today.

Exactly! We're all taught something, and trusting our parents, television, people around us, we tend to get a personal feeling on their opinion, not ours!

It's odd how it works sometimes, the problem occurs when they teach us wrong, and can't undo the mistake.

#25 Re: Help Me ! » In need of a throughout explanation of the following problem: » 2011-10-18 08:09:44

Surely you've been taught something is good or bad in your childhood, morals and such, which you still stick with today.


May I ask you, fine gentleman, how are you today?

Board footer

Powered by FluxBB