# Computer Programming/Physics

## About This Document[edit | edit source]

I have programmed a (working) 2D physics system before and I am currently in college as a Physics Engineering major, so I have experience, but I am by no means an industry expert, so I'm going to start this document and hope that either someone who knows this stuff steps in and takes over or guides me so that I can do this correctly.

Also, if my formatting looks bad, any one can feel free to change it.

`External Party - Added more to the portion of physics. Hopefully not too lengthy or off-topic.

# About Physics[edit | edit source]

Computer programs today simulate physical systems for various purposes, such as realism in games and testing mechanical prototypes before construction. Added with the current trend of increasing processing power, these physical simulations are continually becoming more complicated and elaborate. As such where physics is applicable, programs without these capabilities appear more simple and primitive and thus less desirable compared to programs with these abilities.

Not all programs require the full range of computational capabilities. Most games only require the ability to accurately calculate mechanical processes. Programs like the ones used to test objects need more complex abilities, like calculating the heat given off by the friction between two surfaces. Some programs may even find it desirable to perform pseudo-calculations, calculations based upon physics yet tweaked to achieve a more desirable behavior, or they may just represent a very narrow range of processes that can occur.

When programming physics, various different mechanisms of physics, including branching decisions such as collisions between objects, gravity and any other exertional forces taking effect upon objects present, along with various other elements depending upon the given situation, need to be taken into account and compensated for accordingly.

Each different object has its own mass/weight, which is usually dependent upon the size of the object itself. Effectively programming physics generally entails keeping track of the weight of each object, factoring in other forces such as gravity and collisions while calculating the force of each collision, depending on the object weights and perform an action accordingly.

One example of the weight of objects taking an effect on the world around them would be where, when placed upon another object held up by a weak force would then cause that object to lower towards the ground. The types of physics examples that could be programmed to demonstrate this are virtually endless and, for beginners, it is recommended that they attempt basic examples of physics like gravity.

# Concepts and Programming in Physics[edit | edit source]

## Prerequisites[edit | edit source]

To program for physics or using physics one should be familiar with some widely-applicable concepts and techniques:

- Algebra
- Coordinate Systems
- 2D
- Cartesian (x, y)
- polar - distance and direction (r, θ)
- parametric

- 3D
- Cartesian (x, y, z)
- polar - distance and two angles (ρ, θ, φ)
- parametric

- (Higher dimensions to be addressed under "Relativity")

- 2D
- Trigonometry
- Series Approximations (Pre-Calculus)
- Numerical Methods for Calculus and Differential Equations
- ...

- Iteration
- Matrices and Matrix Math
- Determinant
- Matrix Multiplication
- ...

- Boundary Conditions
- Complex Math (involving )
- Addition of Complex Numbers
- Multiplication of Complex Numbers
- Complex Exponentiation and Logarithms
- Hyperbolic Trigonometry

## Mechanics[edit | edit source]

- Frames of Reference
- Vectors
- Vector Addition
- Dot Product
- Cross Product
- Matrix Product

- Forces
- Momentum
- Energy
- Collisions and Geometric Forces
- Simple Harmonic Motion, Springs
- Friction
- Static Friction
- Kinetic Friction
- Rolling, Wheels
- Friction in Air and Other Fluids
- Hydrodynamics

- Computer programming/Physics/Position of an accelerating body function
- Computer programming/Physics/Position of an accelerating body function (constant acceleration)
- Computer programming/Physics/Motion of an object through space (piecemeal approximation)

## Thermodynamics[edit | edit source]

- Brownian Motion
- Heat and Temperature
- "Zeroth Law"
- First Law
- Second Law
- Third Law