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

This Month's Specials

Air Assault Task Force- Save $8.00
Bronze- Save $10.00

   







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

Reply
 
Thread Tools Display Modes
  #1  
Old August 17th, 2007, 08:02 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

Ah. So I was in the general area.

So...Can I get a hint on where I'm implementing it wrong?
__________________
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
  #2  
Old August 17th, 2007, 09:37 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Looking for a good physics site

You're getting out of the intercept routine a time and a location right?

The ship should simply accelerate at the rate passed into the routine, and in such a direction as to end up at the returned location at the returned time.

That part is just another (Once for each dimension) application of the base formula S(t) = S(0) + Vt +A(t^2).

Within rounding error, the total acceleration will be equal to the acceleration passed into the routine originally.
(Don't forget Pythagoras)
Reply With Quote
  #3  
Old August 17th, 2007, 09:43 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

Uh, I think the formula Jack gave me gives me a time, if used properly.

I have said this before, but to repeat: What rate of acceleration do I pass into the routine and/or where do I get it?

To wit: I have Formula X and Formula Z which require an acceleration number. The acceleration in the X and Z directions will determine which direction the ship will accelerate in. I'm using Formula X and Formula Z (Formula being the one Jack posted) to try to determine in which direction to accelerate. Am I using it wrong or something? Becuase there seems to be some sort of basic miscommunication.

Oh, and I'm only getting one result per axis from that formula. I have no idea how I would get two results out of that formula.
__________________
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
  #4  
Old August 17th, 2007, 10:14 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Looking for a good physics site

The acceleration for X will be cos(theta) times the ship's engine power, while the acceleration for Y will be sin(theta) times the engine power.

And theta will be the direction to accelerate in.

So, lets see. (x,y are coords, * is multiplication)
For X:
S1x-S2x = (V1x-V2x) * T + ((A1*cos(Theta)) -A2x) * T * T
For Y:
S1y-S2y = (V1y-V2y) * T + ((A1*sin(Theta)) - A2y) * T * T

Unknowns are Theta and T, common to both.
You can rearrange the first formula to get Theta = F(T)... there will be inverse cos or inverse sin in it.
Replace the Theta in the second equation with F(T).

Now you've got a big horrid, fearsome beasty with only T as an unknown. Solve for T. You'll probably need a big sheet of paper, or maybe maple to simplify it down to a one-line equation to code in.

Plug T into the first formula again, and Solve for Theta.

Your ship/missile can then accelerate in the direction of Theta for time T. (Theta = 0 means the +X direction, 90 degrees = +Y)
Reply With Quote
  #5  
Old August 17th, 2007, 10:30 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

The acceleration for X will be cos(theta) times the ship's engine power, while the acceleration for Y will be sin(theta) times the engine power.

And theta will be the direction to accelerate in.


Got that far. It's the whole 'How do I calculate theta' that's the problem.

S1x-S2x = (V1x-V2x) * T + ((A1*cos(Theta)) -A2x) * T * T

V1x would be Enemy Velocity X, A1 would be Acceleration Vector Length, Theta would be the angle to accelerate in, A2x would be Target Acceleration X and T would be Time?
What are S1 and S2?

Unknowns are Theta and T, common to both.
You can rearrange the first formula to get Theta = F(T)... there will be inverse cos or inverse sin in it.
Replace the Theta in the second equation with F(T).


What is 'F'?

Now you've got a big horrid, fearsome beasty with only T as an unknown. Solve for T. You'll probably need a big sheet of paper, or maybe maple to simplify it down to a one-line equation to code in.
Now I'm wondering which variation of that formula you gave I should use to figure out T or Theta or whatever it's supposed to give me.
Plus, I think that 'Big sheet of paper' part may put it somewhat outside my mathematical ability.

Plug T into the first formula again, and Solve for Theta.

Your ship/missile can then accelerate in the direction of Theta for time T. (Theta = 0 means the +X direction, 90 degrees = +Y)

Yeah, I may need a bit of help to figure out exactly how to do that.

Going to have to fiddle with the angle, then. C# uses radians for 3d object angles and 0 is +Y (Although I'm using X and Z for horizontal and vertical).

@Jack: That formula you gave me gives Time, right?

I'll go let my brain collapse for a while, then come back and see if I can figure this out. If brute force can figure it out, then I may be able to turtle my way through before my brain starts screaming at me.
__________________
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
  #6  
Old August 17th, 2007, 11:06 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

Let's see if I can de-rust my brain...

Ok, we have: (1/2)(Ax - Ax)(T^2)+(Vx - Vx)T+(Sx- Sx) = 0

Which can be shortened down to (1/2) * A * T^2 + V * T + P = 0
A being Relative Acceleration,
T being Time,
V being Relative Velocity,
P being Position. Because using an S is not intuitive for me.

Why is it equal to 0, though? Pulling numbers out of a hat,
1/2 * 5 * 3^2 + 15 * 3 + 50
2.5 * 9 + 45 + 50
22.5 + 45 + 50
117.5

Um, not equal to zero. That would be total distance covered.
So: (1/2) * A * T^2 + V * T + P = D
D being Total Distance

(1/2) * A * T^2 - D + P = V * T?
1/2 * 5 * 3^2 - 117.5 + 50 = 45?
2.5 * 9 - 117.5 + 50
22.5 + -117.5 + 50
-45

Er, well, sorta. Except that should probably be positive. Also, the reply form should be larger.

(1/2) * A * T^2 + D - P = V * T?
1/2 * 5 * 3^2 + 117.5 - 50 = 45?
2.5 * 9 + 117.5 - 50
22.5 + 117.5 + -50
90

Nope...However, it would work for (1/2) * A * T^2 - D + P = -(V * T)

How am I doing so far?
__________________
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
  #7  
Old August 17th, 2007, 11:17 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Looking for a good physics site

(Position difference) = (speed diff) * T + (Accel Diff) * T * T

After time T, you want the position change due to Speed and Accel to be equal to the current position difference.

I think I missed a negative on the left side:
X1=0; X2=4
V1=0; V2=0
A1=2; A2=0
-(0-4) = 0-0 *T + (2 - 0) * T^2
4 = 2 T^2
T = sqrt(2)
Reply With Quote
  #8  
Old August 17th, 2007, 11:21 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

(1/2) * A * T^2 + V * T + P = D

D - V * T + P = (1/2) * A * T^2

A = 5
T = 3
P = 50
V = 15
D = 117.5

117.5 - 15 * 3 + 50 = (1/2) * 5 * 3^2
117.5 + -45 + 50 = 2.5 * 9
72.5 + 50 = 22.5 // Ok, I know this isn't going to work...
122.5 != 22.5

D - V * T - P = (1/2) * A * T^2
72.5 - 50 = 22.5
22.5 = 22.5

Woot!

BBS
__________________
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
  #9  
Old August 17th, 2007, 11:32 PM
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:
Why is it equal to 0, though?

Brain fried; can't answer post fully at the moment.

That aspect, though...

It's 0 because it's a manipulation of two separate position functions that I want to be in the same place at the same time (definition of interception). They are both position functions, and I want them equal, so I assigned them that way, and tossed the same t in there: p1(t) = p2(t). I then expanded the functions to their components, and merged them onto one side (leaving the other side as 0).
__________________
Of course, by the time I finish this post, it will already be obsolete. C'est la vie.
Reply With Quote
  #10  
Old August 17th, 2007, 11:15 PM
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:
@Jack: That formula you gave me gives Time, right?

They're simultaneous equations - they give time (which can be later used for the x/y of the encounter), and acceleration on both axes when solved together.
__________________
Of course, by the time I finish this post, it will already be obsolete. C'est la vie.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 05:19 AM.


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