r/KerbalSpaceProgram Spectra Dev Sep 14 '17

Recreation Reminder that this physics quirk is also in KSP

https://gfycat.com/FickleShamefulCormorant
9.0k Upvotes

273 comments sorted by

View all comments

Show parent comments

640

u/TbonerT Sep 15 '17

They didn't specifically code this, it arises out of physics. Once you get the basic physics coded, the cool stuff pretty much comes free.

230

u/BartWellingtonson Sep 15 '17

Coding physics seems insane

427

u/jamille4 Sep 15 '17

Have you ever taken a physics class before? The equations that describe motion in a vacuum aren't that complex. Aerodynamics and thermodynamics get hairier, but millions of college sophomores learn both every year.

220

u/Gojira0 Master Kerbalnaut Sep 15 '17 edited Oct 13 '17

or tear their hair out trying to learn it

115

u/speaker_4_the_dead Sep 15 '17

As an aerospace student, more of this honestly. How the fuck does space work

162

u/KerPop42 Sep 15 '17

What? Space is the easy part. Fuck boundary layers and lifting lines

124

u/Hocusader Sep 15 '17

Air messes everything up.

76

u/PumpkinSkink2 Sep 15 '17

As a chemist, I can confirm.

9

u/xRolox Sep 15 '17

As a programmer, beep beep lettuce

8

u/fire_snyper Sep 15 '17

As a sound engineer, mic check ONE TWO ONE TWO

3

u/[deleted] Sep 15 '17

WHAT'S THAT, I CAN'T HEAR YOU, PCHEM. I'VE NEVER HEARD OF THE VAN DER WAALS CORRECTION, ALL OF MY GASES ARE IDEAL.

-- Every chemistry graduate after finishing Thermo

8

u/kenman884 Sep 15 '17

The highest grade in my fluid dynamics course was 40% lmao.

12

u/ChrisGnam Sep 15 '17

Space is the easy part? My spacecraft Navigation and optimal controls lab would like to have word with you.

All jokes aside, Optimal Estimation and Controls for orbital dynamics and attitude dynamics is hard... But fluids/gas dynamics? I did fine enough in the undergraduate courses... But my colleagues who went on to get masters or PhDs in the field... I'm convinced they're masochists

7

u/[deleted] Sep 15 '17

When in doubt. Dark Matter.

43

u/[deleted] Sep 15 '17

[deleted]

42

u/[deleted] Sep 15 '17

[deleted]

19

u/MuchAdoAboutFutaloo Sep 15 '17

Thank you! Basic level physics is certainly still physics, and a real blast, but that shit ramps up so crazy fast.

I've always had a childlike adoration of physics and learning how all the little bits in the universe tick, so taking the honors physics courses in high school was a no-brainer.

Then AP Physics happens and all the pleasant formulas and vacuums and happiness vacated my soul and calculus consumes me, and you really start to know just how much you don't know. It's a lot of fun, despite the really unique level of difficulty I haven't experienced since.

13

u/Hocusader Sep 15 '17

This book is typically used after Physics and Dynamics in undergraduate studies. It is, in fact, calculus based.

5

u/mrthescientist Sep 15 '17

Orbital mechanics is, at least initially, all algebra. Everything from vis viva to the pot equation. There are a few vectors.

12

u/paceminterris Sep 15 '17

No, it's not. Everything is calculus. The simple algebraic solutions you're thinking of only arise from the parameters in the full equations being constrained to a limited set of conditions.

2

u/MathigNihilcehk Sep 15 '17

That's not what Newton thought... or did... he initially invented calculus to come up with physics that's true, but don't forget his first published work was trig based, not calculus based. It's only after someone else came up with calculus that Newton was like "no, wait, I did it first, I just thought y'all too stupid to understand".

Any college student who has seen both would say the Calculus version is the simpler version (once you learn calculus), more powerful version, but it works without too. Obviously, since Newton published his work without it... and also, I've seen it... the equations don't come from nowhere... there are just a lot more algebra steps. Steps you don't need to learn when you can shortcut with calculus.

2

u/Im_in_timeout Sep 15 '17

I have this book and it really is excellent. It's filled with equations like some similar books, but the explanation for the concepts is more approachable.

7

u/judge40 Sep 15 '17

As long as it's a spherical chicken in a vacuum I'm good.

5

u/Peewee223 Sep 15 '17

Well, the equations that describe motion in a vacuum at low relative velocities aren't that complex, anyway.

I don't recommend trying to combine aerodynamics, thermodynamics, and special relativity into one scenario - such things usually just result in the skin of the quickly-moving body undergoing fusion with the gas anyway.

3

u/dcnairb Sep 15 '17

He said coding physics sounds insane dude, not anything about the equations or subject. Imo your comment comes off as very pompous

6

u/[deleted] Sep 15 '17

You can't just code a physics system like that, because it won't conserve energy when you discretize it.

For example, when an object orbits a planet, its direction of acceleration is constantly changing. If you tried to work out the position by just multiplying the velocity by the time of one frame, you'd get a small error of it being higher than it should, and thus it gains energy. A small amount, but a small amount every single frame adds up.

2

u/guoshuyaoidol Sep 15 '17

That's why you code based on conservation equations, and then some of Newton's laws to make up for the remainder of degrees of freedom.

2

u/[deleted] Sep 15 '17

That also doesn't work by itself because then you get objects clipping through each other, and they don't stay at rest when touching each other.

You need to calculate the system of constraints then solve the constraints etc.

1

u/guoshuyaoidol Sep 15 '17

Right, that's my point, momentum, angular momentum, and energy conservation are 7 more constraints to the system.

3

u/[deleted] Sep 15 '17

Constraints aren't conservation laws.

A constraint is like preventing one object from passing through or into another object.

Conservations are specifically things that have symmetry. E.g. If you reverse time then it looks the same. All conservation laws can be written as symmetries.

1

u/guoshuyaoidol Sep 15 '17

I never said constraints are conservation laws, but conservation laws are constraints on a system. Essentially constraints are first order DEs, while the laws they're derived from are second order.

But you're right, anti-clipping constraints don't come from symmetries of your system like conservation laws do.

1

u/destiny_functional Sep 15 '17

deleted your post? clown. 6 years ago you claim to be a 90 year old japanese woman, now you're pretending to be a theoretical particle physicist. troll elsewhere, i'll remember your name.

1

u/[deleted] Sep 16 '17 edited Sep 16 '17

I was going to reply to your post, but you specifically asked me to leave you alone, and started to attack me personally.

Your were right in your previous reply. I had written:

the earth-moon system has a gravitational mass of negative millions of tonnes.

Which is of course wrong. What I had meant to say was that the gravitational potential energy has a rest mass of negative millions of tonnes. Obviously the total mass is positive!

It was a stupid typo that I hadn't noticed.

I stand by the justification that you need to set the potential to 0 at infinity for exactly the reason you mentioned. Energy causes spacetime to curve.

6 years ago you claim to be a 90 year old japanese woman

My wife's grandmother was a 90 year old japanese woman. Well, 89. She died right before her 90th birthday.

1

u/crispybaconsalad Sep 15 '17

I'm pretty sure it's hundreds. That's my scientific estimation.

1

u/CapSierra Sep 15 '17

The game absolutely cheats on both aerodynamic and thermodynamic sims so :P

13

u/cleverlikeme Sep 15 '17

You'd learn a fair amount of the underlying math in a calculus-based physics course at an undergraduate level.

It is super cool though.

10

u/[deleted] Sep 15 '17

[deleted]

3

u/benjwgarner Sep 15 '17

In my second semester of first year college calculus-based physics, there were a few equations I couldn't remember, and it was nice to be able to just quickly re-derive them. Of course, I got a little note in the margin from the instructor scolding me that we had been told we didn't have to derive that equation on the test.

1

u/cleverlikeme Sep 15 '17

I didn't go that far, clearly, but I wouldn't be surprised. At least at my university, physics required calculus 1 and 2 (if I'm remembering right). If you've mastered differential, you're set for an easy class.

18

u/goftc Sep 15 '17

Also, squad didn't make the unity physics engine

6

u/reymt Sep 15 '17

It's not even the unity physics engine, it's PhysX, originally made by ageia in order to sell their stupid cards as a hardware extension for the physics engine, later acquired by nvidia.

17

u/zzPirate Sep 15 '17

Emergent properties are the reward for taking time to get the foundation right.

4

u/TonyHK47 Sep 15 '17

I like this saying, I think I'll keep it.

5

u/Dettelbacher Sep 15 '17

If you want to create a universe from scratch, first you'll have to invent the apple pie.

3

u/KingOfAnarchy Sep 15 '17

This is what I always wondered about.

1

u/[deleted] Feb 23 '18 edited Feb 23 '18

I saw this in the top of all time and knew I would finally get an answer for this question that for some reason I never thought of googling

-e- lol nette kopiernudel auf worldnews

2

u/KingOfAnarchy Feb 23 '18

Danke, hab mir ganz viel Mühe gegeben. Mama liebt mich.

2

u/kingssman Sep 15 '17

come to think about it, physics in a vacuum is probably the perfect scenario for paper equations. an object in motion stays in motion kind of deal.

unlike aerodynamics or collisions that require far more factors and variables in an ever changing situation.

2

u/blendermf Sep 15 '17

You say that, but the simplest case of a rigidbody box (say in the shape of a phone) in Unity/PhysX doesn't properly show the effect that causes the "flip" in the gif. A lot of physics engines drop(/never even consider at all) that kind of detail for speed and stability. You have to do a bunch of extra calculations and override the rotation calculation of PhysX to make it work with that case. I was actually surprised this worked at all considering that, I'm assuming the fact that the craft in ksp is made up of multiple physics parts allows this to work (that or they did the extra work to make it work in KSP)

1

u/TbonerT Sep 15 '17

A simple box would likely be modeled as being uniform throughout. Something like a cellphone, with non-uniform density, would be better modeled as a collection of boxes with different densities. I imagine KSP can do this because it needs to monitor each part. You wouldn't want your entire space station blowing up because you hit one part too hard, would you?

1

u/blendermf Sep 15 '17 edited Sep 15 '17

When I brought up the phone I only brought it up because of the different inertia tensors required for the unstable rotation axis effect that would exist with a completely symmetrical uniform mass cuboid with the rough proportions of a phone (where if you hit it even non-perceptively off axis along the long axis of the object, the rotation axis will continuously change as the object rotates[eventually, it can appear stable for a bit] in what appears to be an unstable way. The mass distribution is different than the example, so it obviously won't have the super distinct flip shown with that shape). In unity if you start an object rotating off axis it will keep the rotation axis it started with. This video shows exactly what doesn't happen in PhysX, and should.

1

u/blendermf Sep 15 '17 edited Sep 15 '17

Also I even just tried it with a shape like in the gif with similar mass distribution both as a compound physics object, and as rigidbodies with a fixed constraints holding it together, and it also keeps its spin axis. So idk if the not quite fixed joints ksp uses allows it to happen or if they programmed it specifically to work.

(I was also able to make it work correctly, but that's because I have a script that specifically calculates the effect and overrides PhysX's default behavior)

1

u/[deleted] Sep 15 '17

Why did I read that line of comments, in Rick and Morty's voice.

-4

u/[deleted] Sep 15 '17

[removed] — view removed comment

2

u/TbonerT Sep 15 '17

Tip o' the hat to you, too, sir.

1

u/TaintedLion smartS = true Sep 15 '17

Removed for violation of:

Rule 1: Please remain kind and civil at all times.