Created
November 29, 2015 06:52
-
-
Save vadixidav/0f6522f854ea4d1588fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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