Science!

View previous topic View next topic Go down

Science!

Post by DanielLC on Mon Oct 25, 2010 7:10 pm

A while back, I wanted to make an auto-turret capable of leading. This requires knowing how fast the bullets move. There wasn't anything on the documentation, so I had to do science.

Code:
Val{
  Engine(min=-2000,max=3000,step=500)
  Steering(min=-20,max=20,step=1)
  TurretArm(default=90,min=0,max=100)
  TurretY(min=-480,max=480)
  TurretPower(min=0,max=100000,step=100000)
  Time(default=0,min=0,max=999)
  X(default=0,min=-9999,max=9999)
  Z(default=0,min=-9999,max=9999)
  VX(default=0,min=-9999,max=9999)
  VZ(default=0,min=-9999,max=9999)
  D1(min=0,max=9999)
  T1(min=0,max=9999)
  reset(default=1,min=0,max=1)
}
Key{
  0:Engine(step=100)
  1:Engine(step=-100)
  2:Steering(step=-1)
  3:Steering(step=1)
  4:reset(step=-1)
}
Body{
Core(){

N:Rudderf(angle=steering){
  E:Trim(angle=-20){
      E:Wheel(angle=90){}
  }
  W:Trim(angle=20){
      W:Wheel(angle=90){}
  }
}
S:Frame(){
  E:Trim(angle=-20){
      E:Wheel(angle=90,power=Engine){}
  }
  W:Trim(angle=20){
      W:Wheel(angle=90,power=-Engine){}
  }
}

S:Frame(angle=90,option=1){
  N:Trimf(angle=turretY){
      N:Arm(angle=turretArm,name=GUN,power=TurretPower,option=100000){}
  }
}

}
}

Lua
{
function mod(n)
if n>180 then return n-360 end
if n<=-180 then return n+360 end
return n
end

function sqr(n)
return n*n
end

function main()

TIME=TIME+1
if TIME >= 30 then
  if RESET == 0 then
    TIME = 0
    TURRETPOWER=100000
  end
end

ax=VX-_OX()+X
az=VZ-_OY()+Z

VX=_OX()-X
VZ=_OY()-Z
X=_OX()
Y=_OY()
Z=_OZ()

_SETCOLOR(666666)
_MOVE3D(X,Y,Z)
_LINE3D(_X(GUN),_Y(GUN),_Z(GUN))

DISTX=X-_X(GUN)
DISTY=Y-_Y(GUN)
DISTZ=Z-_Z(GUN)

d=math.sqrt(sqr(DISTX)+sqr(DISTY)+sqr(DISTZ))

a=10*(ax*DISTX+az*DISTZ)/d

if a<=-0.05 then
  if RESET==0 then
    D1=d
    T1=TIME
    RESET=1
  end
end
out(0,a)
out(1,RESET)
out(2,D1)
out(3,T1)

ROTATION=mod(math.deg(math.atan2(DISTZ,DISTX)+_AY())-270)

if mod(TURRETY-ROTATION)<0 then
 
  if mod(TURRETY+5-ROTATION)>0 then
      TURRETY=math.floor(ROTATION+0.5)
  else
      TURRETY=mod(TURRETY+5)
  end

elseif mod(TURRETY-ROTATION)>0 then

  if mod(TURRETY-5-ROTATION)<0 then
      TURRETY=math.floor(ROTATION+0.5)
  else
      TURRETY=mod(TURRETY-5)
  end
end

ANGLE=math.deg(math.atan2(math.sqrt(DISTZ^2+DISTX^2),DISTY)-math.sqrt(_AX()^2+_AZ()^2))

if TURRETARM<ANGLE then

  if TURRETARM+5>ANGLE then
      TURRETARM=math.floor(ANGLE+0.5)
  else
      TURRETARM=TURRETARM+5
  end

elseif TURRETARM>ANGLE then

  if TURRETARM-5<ANGLE then
      TURRETARM=math.floor(ANGLE+0.5)
  else
      TURRETARM=TURRETARM-5
  end
end

end
}

This is a modified auto-aiming turret. I can't remember who made it originally. As it is now, press h to create a ball, and press z to start firing until you get your next data point. The third line on the top left is the distance, and the fourth is the time in frames.

Here's my data:

Code:
43.89   3
54.87   3
80.93   5
53.33   3
47.24   3
44.80   3
42.4   3
35.2   2
35.79   2
16.61   1
39.55   2
116.11   6
122.83   7
150.24   8
120.53   6



This gives a bullet speed of 1/0.05041041 = 19.8 meters per frame, so I'm betting it's supposed to be 20. This is when using 30 FPS. Feel free to repeat the experiment yourselves.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by bwansy on Tue Oct 26, 2010 12:16 am

That is an excellent experiment. Indeed, the bullet speed in air is 600m/s, which has been verified by experiments done by many of us, and is put into practical use. Be aware that the velocity of the gun is added to the bullet, so keep that in mind if you are going to mount the turret onto a vehicle.

Good luck! Very Happy

_________________
A.K.A. Bernard

bwansy
Admin

Posts : 170
Join date : 2010-07-15

View user profile http://rigidchips.forum-motion.com

Back to top Go down

Re: Science!

Post by T-Bouw on Tue Oct 26, 2010 1:34 am

As a side note:
The maximum distance a bullet-particle'll have effect is 200 meters.
I believe I got this info. from you bwansy.
avatar
T-Bouw
Car
Car

Posts : 22
Join date : 2010-07-22
Age : 34
Location : The Netherlands

View user profile

Back to top Go down

Re: Science!

Post by bwansy on Tue Oct 26, 2010 4:35 am

It should be 1.2km. The effective time of a bullet is 2 seconds.

I once tried breaking this range by increasing the speed of the bullets, using a modified chaingun that instantaneously accelerate its guns at the moment of firing, but it had no significant effect. On the other hand, it was horrendously inaccurate, which, at the distance of 1.2km, rendered it practically useless. Laughing

_________________
A.K.A. Bernard

bwansy
Admin

Posts : 170
Join date : 2010-07-15

View user profile http://rigidchips.forum-motion.com

Back to top Go down

Re: Science!

Post by T-Bouw on Tue Oct 26, 2010 9:49 am

Ha! I stand corrected. Thanks.

Oh of course!
Maximum time ingame for a bullet-particle was 2 seconds, 600m/s, which translates to 1200 meters.
I don't know where I got that 200 from then....
Sorry for the mis-information. My bad. No
avatar
T-Bouw
Car
Car

Posts : 22
Join date : 2010-07-22
Age : 34
Location : The Netherlands

View user profile

Back to top Go down

Re: Science!

Post by DanielLC on Thu Oct 28, 2010 9:00 pm

You should post all that stuff somewhere. I have a few other things I need. I'm perfectly willing to do the tests myself, but if you guys know, I'd rather you just tell me.

What is the force of gravity? That is to say, if I power a jet facing straight down, how many times the _WEIGHT() does it need to be to get the thing to hover?

How does the game calculate moment of inertia? Does it treat squares as squares, discs as discs, etc, or does it treat everything as squares, or even just treat everything as spheres?

Also, I don't have anything that needs this now, but:

How quickly does a force of _WEIGHT() cause something to accelerate?

What's the coefficient of friction in the air? On the ground? In the water?

What's the maximum speed? Does it apply to each chip individually, just the core, or just the center of mass?

From testing I've done, it seems that a bullet generates just as much thrust as a jet given the same power for one frame, plus a random amount in a random direction. How much is that amount?

Perhaps they should make a separate science sub-forum.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by JHaskly on Fri Oct 29, 2010 12:27 am

Gravity = ~9.81 m/s/s.

Every unit of power of a jet is equal to a sixth of a newton. So _WEIGHT()*9.81*6 should keep you up Smile

As for friction, I'm not sure of the amounts, but (on land), each chip typpe has an individual friction rating. And, as you may have found out, jets have no air resistance.

Maximum speed of the core is 140m/s, max speed of anything else is 175m/s. The force of bullet recoil is _OPTION(of the gun)/6 newtons. So a jet and a gun where the option and power equal will cancel eachother out.

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: Science!

Post by madbob2 on Fri Oct 29, 2010 1:30 am

I'm happy to see that we have new members that like the science behind RC, instead of the GUNS!!! Dun dun dunnnnn! So welcome to the forum Daniel
avatar
madbob2
Tank
Tank

Posts : 87
Join date : 2010-07-16
Age : 20
Location : Orz Lake.x

View user profile

Back to top Go down

Re: Science!

Post by DanielLC on Sat Oct 30, 2010 12:05 am

Who said I don't like guns? Why did you think I was asking about making jets and guns cancel out? That said, it's not necessary. I've built several models entirely without guns, and guns alone aren't enough to justify a model.

I'm not actually all that into the science. I generally prefer reading the documentation. I am, however, into the math and engineering.

I'm not actually new here. I've come here earlier at two points, but I think the forums have changed more often than that.

Speaking of which, should I resubmit my old files?

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by JHaskly on Sat Oct 30, 2010 5:51 am

If the old files are worth re-submitting, then please do!

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: Science!

Post by DanielLC on Sun Oct 31, 2010 3:55 pm

_WEIGHT()*9.81*6 seems to keep me up okay, but _WEIGHT()*6*30*velocity won't seem to stop me in one frame. It seems to take _WEIGHT()*6*1000 or so. Any idea why?

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by JHaskly on Mon Nov 01, 2010 12:35 am

I would have thought it would be _WEIGHT()*6*30*velocity, but if it isn't working...

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: Science!

Post by bwansy on Mon Nov 01, 2010 10:10 am

Are you talking about the damping term or the constant term? "Something*velocity" would be the damping term, which dissipates the oscillation. It can be any number you like (with the correct +/- sign of course), but if you make it too large it would shake uncontrollably.

_________________
A.K.A. Bernard

bwansy
Admin

Posts : 170
Join date : 2010-07-15

View user profile http://rigidchips.forum-motion.com

Back to top Go down

Re: Science!

Post by JHaskly on Tue Nov 02, 2010 12:39 am

Bwansy, I think Daniel is attempting to stop the vehicle in a signlle frame.

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: Science!

Post by DanielLC on Thu Nov 04, 2010 8:28 pm

What can I say? I'm impatient.

I did some more science. It appears that at 30 FPS, it takes WEIGHT()*6*900. At 15, it takes WEIGHT()*6*225.

Any idea why it would be proportional to the square of the FPS?

It seems to take WEIGHT()*6*9.81 to hold it up.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by JHaskly on Fri Nov 05, 2010 12:23 am

How... odd. Never encountered that before.

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: Science!

Post by bwansy on Fri Nov 05, 2010 1:31 am

My hypothesis: Because the force is so large, some chips might theoretically exceed the speed limit of 140m/s. But since velocity is capped at 140m/s in RC (if the chips are attached to the Core), it would make it appear that it's breaking the laws of physics (in fact it is).

I have written a scenario file a while ago that might come in handy. It can pause simulation in RC for frame-by-frame analysis. I'll post it in the Scripts forum.

EDIT: Here albino

_________________
A.K.A. Bernard

bwansy
Admin

Posts : 170
Join date : 2010-07-15

View user profile http://rigidchips.forum-motion.com

Back to top Go down

Re: Science!

Post by DanielLC on Fri Nov 05, 2010 3:53 pm

My hypothesis is that, in order to keep the jets from being too problematic, they take a second to get from full power. If I have it at 30 FPS, this means it's only at a 30th of it's power on the first frame, and since I want it to stop in one frame, I have to make it 30 times that, making it WEIGHT()*6*900. If it's only 15 FPS, similar logic yields WEIGHT()*6*225.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: Science!

Post by bwansy on Sat Nov 06, 2010 3:54 am

Changes in jet powers are instantaneous.

_________________
A.K.A. Bernard

bwansy
Admin

Posts : 170
Join date : 2010-07-15

View user profile http://rigidchips.forum-motion.com

Back to top Go down

Re: Science!

Post by RA2lover on Sat Jul 13, 2013 9:43 am

largest bump ever, but i still think it should be done in the name of science.

DanielLC wrote:You should post all that stuff somewhere. I have a few other things I need. I'm perfectly willing to do the tests myself, but if you guys know, I'd rather you just tell me.

What is the force of gravity? That is to say, if I power a jet facing straight down, how many times the _WEIGHT() does it need to be to get the thing to hover?

How does the game calculate moment of inertia? Does it treat squares as squares, discs as discs, etc, or does it treat everything as squares, or even just treat everything as spheres?

Also, I don't have anything that needs this now, but:

How quickly does a force of _WEIGHT() cause something to accelerate?

What's the maximum speed? Does it apply to each chip individually, just the core, or just the center of mass?

From testing I've done, it seems that a bullet generates just as much thrust as a jet given the same power for one frame, plus a random amount in a random direction. How much is that amount?

Perhaps they should make a separate science sub-forum.


What is the force of gravity? That is to say, if I power a jet facing straight down, how many times the _WEIGHT() does it need to be to get the thing to hover?

9.807m/s². raw _DT corrected value(which suffers from eventual floating point fluctuations) - 9.807042121887207m/s²

How does the game calculate moment of inertia? Does it treat squares as squares, discs as discs, etc, or does it treat everything as squares, or even just treat everything as spheres?
the game seems to treat squares as squares, i'm not sure about other types of chips.

How quickly does a force of _WEIGHT() cause something to accelerate?
0.1m/s. scenario: plain core model, apply _WEIGHT() force to it, measure changes in velocity then correct them with _DT

What's the coefficient of friction in the air? On the ground? In the water?
it's apparently polynomial, as http://rigidchips.forum-motion.com/t476-air-drag-in-rigidchips indicates. air density is the same from 0~300m then decreases linearly to 0 from 300 to 10km, where it stays at 0. i don't have underwater research data,as both buoyancy and pressure(applied to the center of mass of the body) forces apply there.

What's the maximum speed? Does it apply to each chip individually, just the core, or just the center of mass?
140m/s for the core, 175m/s for other chips, applies to the center of mass of each chip. you also have a maximum angular velocity of 50k RPM(tested for wheels/RLWs only at the moment). fun fact: pressing Y gives a force enough to accelerate the core by 10m/s in one frame. note: this can be changed by external mods

From testing I've done, it seems that a bullet generates just as much thrust as a jet given the same power for one frame, plus a random amount in a random direction. How much is that amount?
none. experiment: have an arm split itself from other parts without gravity/air friction, then fire it and measure its velocities.
avatar
RA2lover
Walker
Walker

Posts : 382
Join date : 2010-10-11
Age : 22
Location : Brazil

View user profile

Back to top Go down

Re: Science!

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum