.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
World Supremacy- Save $9.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #11  
Old August 17th, 2007, 02:21 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Looking for a good physics site

Aren't those pretty much the equations we came up with last time, Narf? I think we used a slightly different form of acceleration equation, but it amounts to the same thing.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #12  
Old August 17th, 2007, 02:26 AM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Looking for a good physics site

There's a resemblance, but I'm pretty sure there was no distance, 4ac or 4a.

In any case, something about my implementation is off, possibly having something to do with the questions I asked.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #13  
Old August 17th, 2007, 02:29 AM
Jack Simth's Avatar

Jack Simth Jack Simth is offline
Major General
 
Join Date: Oct 2002
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
Jack Simth is on a distinguished road
Default Re: OT: Looking for a good physics site

Quote:
narf poit chez BOOM said:
Tankee! Tankee very much!

...But, um, if the enemy acceleration needs to be chosen to use the formula and the formula tells it in which direction to accelerate and thus, how much to accelerate...

...Isn't that a closed loop?

Nope. You have a second, identical equation for the other dimension (or more - it's extendable to as many as you like; most games will use two (X, Y), some will use three (X, Y, Z) but you can have 30 if you feel like it), and you'll have a relationship between the two based on the overall max acceleration for the pursuer (based on the pythagorean therom; max acceleration = sqrt(a(x)^2 + a(y)^2 + a(z)^2 + ... ) and the persuer is picking an acceleration in the x, y, z, ... axises (axen? axes? - what's the plural of axis?); you'll end up with a system of equations, based on how much you're simulating.

It's simultaneous equations. If you've got four variables and three equations that relate them, you can usually solve for everything in terms of a single variable.
Quote:
narf poit chez BOOM said:

/me goes off to see what happens if /me uses that by inputing '0' for the enemy acceleration.

...Uh, the first one is the pursuer, right?

Whichever you'd prefer; the exact choice is completely immaterial. Math's like that, sometimes.
Quote:
narf poit chez BOOM said:

...'+/-'?
The Quadratic formula gives two results. One will usually give you negative time, which you discard. Occasionally it will come back with an imaginary number (by way of the square root of a negative) - in which case, interception is not possible.

Oh, and there's a REASON most games use flat velocities, rather than accelerations.

The simple way to do it, if you're going a little bit at a time anyway, is to simply accelerate in the direction of the target. The computer will have some overshooting issues, and it won't be the most efficient course, but it'll do the job eventually.
__________________
Of course, by the time I finish this post, it will already be obsolete. C'est la vie.
Reply With Quote
  #14  
Old August 17th, 2007, 02:34 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Looking for a good physics site

There was distance. In fact, I'm pretty sure it was the position equation, now that I think about it. We never plugged it into the zeros-solving quadratic equation, hence no 4ac.

+/- is from the quadratic equation. There are two zeros (values of x where the curve intercepts the x axis and y is zero) in the solution to every quadratic equation. The handy cheat sheet formula compacts them into the same function, which varies only by making one version a + and the other a - where that +/- symbol goes.

===

The thing about the position function is that it assumes constant acceleration of both parties. It is calculating how much time passes until the objects intercept. From this, you can plot out where they intercept and get the necessary angle of motion. Remember that you had to do this every so often to find a new intercept heading, based on changes to the acceleration vectors of both objects.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #15  
Old August 17th, 2007, 02:36 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Looking for a good physics site

Quote:
Jack Simth said:
what's the plural of axis?
"axes," pronounced like "ax'eees."
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #16  
Old August 17th, 2007, 02:50 AM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Looking for a good physics site

Nope. You have a second, identical equation for the other dimension (or more - it's extendable to as many as you like; most games will use two (X, Y), some will use three (X, Y, Z) but you can have 30 if you feel like it), and you'll have a relationship between the two based on the overall max acceleration for the pursuer (based on the pythagorean therom; max acceleration = sqrt(a(x)^2 + a(y)^2 + a(z)^2 + ... ) and the persuer is picking an acceleration in the x, y, z, ... axises (axen? axes? - what's the plural of axis?); you'll end up with a system of equations, based on how much you're simulating.

Er, yes, I'm currently using it for two axis. Three would probably result in a significantly smaller consumer base. Four would limit it to only the seriously dedicated, which does not include me, in both desire and ability.

I do know that equation. My problem is the whole 'Pursuer picking an acceleration' thing. See, the equation helps pick the pursuers' acceleration and the pursuers' acceleration is part of the equation...

Um, there must be something obvious I'm not seeing. Possibly it's in the communication.

It's simultaneous equations. If you've got four variables and three equations that relate them, you can usually solve for everything in terms of a single variable.

I get the general concept. However, my math skills are abysmal. I still carry a grudge with the school system here over that; they were near-genius level before I entered it. (I have a psychiatric assesment to prove it, too).

I am trying to raise my math skills. I have learnt a few things bashing my head against this.

Whichever you'd prefer; the exact choice is completely immaterial. Math's like that, sometimes.

Er, do you mean I can put '0' for the pursuers' acceleration or I can use either for the pursuer or both? Because I can see the second, but I'm not sure about the first.

The Quadratic formula gives two results. One will usually give you negative time, which you discard. Occasionally it will come back with an imaginary number (by way of the square root of a negative) - in which case, interception is not possible.

The negative time would explain the enemy ship accelerating south if it's headed south and sufficiently southward of the target.
If the result is not a number or infinity, it is discarded.

So, uh, how do I make sure the formula is giving me a good result?

Oh, and there's a REASON most games use flat velocities, rather than accelerations.

My left brain is perfectionist, precise and thorough. I believe you are all sufficiently aquanted with my right brain...

...Besides, one of the main features of this game will be multiple FTL and STL systems.

The simple way to do it, if you're going a little bit at a time anyway, is to simply accelerate in the direction of the target. The computer will have some overshooting issues, and it won't be the most efficient course, but it'll do the job eventually.

That would be a whole lot easier. But my brain has consistantly discarded that option in favour of the better (In the end) result.

Although it is getting tempting.

Ok, my brain is seriously fried and it's rather late. I'll look at this again tomorrow.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #17  
Old August 17th, 2007, 06:05 AM
dogscoff's Avatar

dogscoff dogscoff is offline
General
 
Join Date: Mar 2001
Location: UK
Posts: 4,245
Thanks: 0
Thanked 0 Times in 0 Posts
dogscoff is on a distinguished road
Default Re: OT: Looking for a good physics site

Quote:

The simple way to do it, if you're going a little bit at a time anyway, is to simply accelerate in the direction of the target. The computer will have some overshooting issues, and it won't be the most efficient course, but it'll do the job eventually.
A variation on this which may (or may not) work better would be:

Missile looks at where target is now, and figures how much time it would take the missile to accellerate in a straight line and get to that point. Lets say it predicts it could get there at time U.

Missile now predicts where target will be at time U based on target's current course and accelleration. Lets call this Location K. (I like picking random letters to use a variables, it bugs reals mathematicians/ scientists=-).

Missile begins accelerating towards K.

Every time the target changes course or acceleration, go back to square one.

When missile gets within a certain "kill range" of the target, it startss accellerating directly toward the target instead of some predicted future position.

Again, it's not perfect. Overshooting may still occur (but less so than if always accellerating directly at the target), and it might do crazy things if the target takes violent evasive maneuvers, but it seems to me it ought to generate something akin to a decent intercept. As a bonus, it only has to recalculate when the target changes course, instead of all the time, thus saving you CPU cycles.

Just a thought.
Reply With Quote
  #18  
Old August 17th, 2007, 03:59 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Looking for a good physics site

@Dogscoff: That would generate a pretty good intercept, but it wouldn't be perfect. To get a perfect intercept, you also have to calculate how far the target moves while the enemy is moving to where it will be then. Thanks for the idea, though.

There was distance. In fact, I'm pretty sure it was the position equation, now that I think about it. We never plugged it into the zeros-solving quadratic equation, hence no 4ac.

By 'distance' I meant we didn't take into account position. That wasn't worded well.

+/- is from the quadratic equation. There are two zeros (values of x where the curve intercepts the x axis and y is zero) in the solution to every quadratic equation. The handy cheat sheet formula compacts them into the same function, which varies only by making one version a + and the other a - where that +/- symbol goes.

So I should make two formulas, one with a '+' there and the other with a '-' there and if one returns a zero, I use the other?

The thing about the position function is that it assumes constant acceleration of both parties. It is calculating how much time passes until the objects intercept. From this, you can plot out where they intercept and get the necessary angle of motion. Remember that you had to do this every so often to find a new intercept heading, based on changes to the acceleration vectors of both objects.
I did get that.

This is what I have currently.

...Erm, does that formula give the distance that will be covered or the time to cover it?
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #19  
Old August 17th, 2007, 05:04 PM
AngleWyrm's Avatar

AngleWyrm AngleWyrm is offline
Second Lieutenant
 
Join Date: Mar 2005
Location: Seattle, WA
Posts: 417
Thanks: 0
Thanked 0 Times in 0 Posts
AngleWyrm is on a distinguished road
Default Re: OT: Looking for a good physics site

Quote:
narf poit chez BOOM said:
I'm trying to code intercept calculations for two spaceships, both capable of velocity, acceleration and different positions.
The problem is in framing the question. So let me ask you about what you are trying to achieve: Does a dog chase a cat by predicting where the cat will be next frame? Does a Cheetah hunt a deer by moving towards a calculated destination? The answer of course is no.

What we are trying to implement here can be described by fighter pilots: The three modes of persuit are Pure Persuit, Lag Persuit, and Lead Persuit. Pure Persuit is probably most familiar. It involves pointing your nose directly at the target. Heat seaker missiles follow this course. Unfortunately, so do a lot of weak AI opponants. It is also fairly easy to outmaneuver; just turn so that the enemy is sleightly behind you and you will arc around him.Lag Persuit is what a dog does to a person. He points his nose behind the target, and this changes the way his target is facing fastest. It brings him around to the rear of his opponant.Lead Persuit is what is what is meant by an "intercept course", and involves pointing your nose in front of your opponant. It's what children playing a game of tag do.

On to an intercept algorithm. Instead of percieving the universe as a set of coordinates from "above", consider a 'ground-level' view. What you can do is turn to place him at any angle from you. You could turn to put him in your 12:00--dead ahead. What you can watch is what angle he is presenting to you. If you are in his 6:00 he is running straight away from you.

Let's start by saying you are both the same speed. We'll add speed difference in a moment. If he is facing directly at you, or directly away from you, then you should turn to face directly at him. What if he is facing so that you are in his 9:00 or 3:00 -- directly abreast of his run? Then you will have to run in the same direction on a parallel course until something changes. Do that by turning to put him in your 3:00/9:00.

So now we have straight-on, and parallel-course; 0~90 degrees, based on his presentation of 0~90 degrees. these are the two extremes, and the only thing left is to figure out what the middle values should be. It's easy enough for dumb animals, so we should be able to 'get it'. As the target turns more and more away from dead-on, so should you. Atan2 of his angle gives the fraction.

Now about that speed difference. If you are moving twice as fast as the target, then cut the angle change in half. Pretty cool, huh?
Reply With Quote
  #20  
Old August 17th, 2007, 05:17 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Looking for a good physics site

You just gave me a formula I already tried. It worked for velocity.

Also, you probably didn't mean to, but your post comes across as condescending.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:39 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.