-
Notifications
You must be signed in to change notification settings - Fork 0
/
CampoEletrico.pde
50 lines (37 loc) · 963 Bytes
/
CampoEletrico.pde
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class CampoEletrico{
public Particula p;
public float aceX, aceY, camp;
public PVector ace;
public boolean b, inicioCampo, giroCampo;
public CampoEletrico(float camp, Particula p){
this.camp = camp;
this.aceY = 0;
this.aceX = ((camp * p.carga)/p.massa);
b = true;
inicioCampo = false;
giroCampo = false;
ace = new PVector(aceX, aceY);
}
void rotate2D(PVector ace, float anguloDeRota) {
float m = ace.mag();
float a = ace.heading();
a += anguloDeRota;
ace.x = m * cos(a);
ace.y = m * sin(a);
}
void iniciarCampoEletrico(Particula p){
if(keyPressed == true && key == 'v'){
inicioCampo = true;
}
if(keyPressed == true && key == 'b'){
giroCampo = true;
}
if(giroCampo){
c.rotate2D(c.ace, PI/300);
}
if(inicioCampo){
p.vel.add(ace);
drawVector(c.ace, p.pos.x, p.pos.y, 5000);
}
}
}