mirror of
https://github.com/Noratrieb/redox.git
synced 2026-01-14 16:25:04 +01:00
added mass
This commit is contained in:
parent
1888dca4e8
commit
10ca04b98e
5 changed files with 19 additions and 66 deletions
|
|
@ -12,18 +12,18 @@ const RANDOM_ACCELERATION = 2;
|
|||
export default class Particle implements SimObject {
|
||||
private _position: Vector;
|
||||
private _velocity: Vector;
|
||||
// private _color: FillStyle;
|
||||
private _mass: number;
|
||||
private _charge: number;
|
||||
|
||||
constructor(position: Vector, /*color = "black", */charge = 0) {
|
||||
constructor(position: Vector, charge = 0, mass = 1) {
|
||||
this._position = position;
|
||||
this._velocity = new Vector();
|
||||
//this._color = color;
|
||||
this._charge = charge;
|
||||
this._mass = mass;
|
||||
}
|
||||
|
||||
public applyForce(force: Vector) {
|
||||
this._velocity = this._velocity.add(force);
|
||||
this._velocity = this._velocity.add(force.scaleInverse(this._mass));
|
||||
}
|
||||
|
||||
public draw(ctx: Ctx): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue