repl.it
@uint9000_t/

particles

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Particle2d {
  //god i love type systems. why am i not using typescript
  constructor (args) {
    this.m = typeof args.m !== "Number" ? 1 : args.m; //mass
    this.v = typeof args.v !== "Object" ? {x:0,y:0} : args.v; //velocity
    a = typeof args.a !== "Object" ? {x:0,y:0} : args.a; //acceleration
    mu = typeof args.mu !== "Number" ? 0 : args.mu; //coefficient of friction
    pos = typeof args.pos !== "Object" ? {x:0,y:0} : args.pos; //position (cartesian)
    dim = typeof args.dim !== "Object" ? {w:1,y:1} : args.dim;
    charge = typeof args.charge !== "Number" ? 0 : args.charge;
  }
  //velocity vector, for those that hate cartesians
  get vVector() {
    
  }
  set vVector(val) {
    
  }
}

/*
    |\
    |  \    vVector.v
v.y |    \
    |      \
    |_______(\ vVector.th
      v.x
*/

let part = new Particle2d({m:2});
console.log(part.m);
?