Skip to content

Instantly share code, notes, and snippets.

@vadixidav
Created November 29, 2015 06:52
Show Gist options
  • Save vadixidav/0f6522f854ea4d1588fa to your computer and use it in GitHub Desktop.
Save vadixidav/0f6522f854ea4d1588fa to your computer and use it in GitHub Desktop.
pub trait CrossPhysicsParticle<V, D>: PhysicsParticle<V, D>
where V: CrossVector<D>, D: Float
{
//Apply lorentz forces between two PhysicsParticle objects based on quanta, position, and velocity
fn lorentz(&mut self, rhs: &mut Self) {
let delta = rhs.position() - self.position();
let distance = delta.displacement();
let force = rhs.velocity().cross(&self.velocity().cross(&delta)) * self.quanta() * rhs.quanta() /
distance.powi(3);
let acceleration = -force / self.inertia();
self.accelerate(acceleration);
let acceleration = force / rhs.inertia();
rhs.accelerate(acceleration);
}
//Apply lorentz forces on one object based on a field at the particle's location
//fn lorentz(&mut self, field: V);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment