3b1b / 3b1b/manim

Field of MovingCharges continual update

Aberta
#1,120 2 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
93.9k
Forks
7.7k
Merge médio
2d 13h
PRs com merge (30d)
4

Descrição

Following Todd Zimmerman's tutorial[ _Getting Started Animation with Manim and Python 3.7_](https://talkingphysics.wordpress.com/2019/01/08/getting-started-animating-with-manim-and-python-3-7/) on Chapter 10, he presents continual update for vector fields.
Everything previously worked perfectly. However continual update doesn't seem to work.
Other similar issues on the Github Issues has returned an error, however it is not my case.
In my case, the code runs fine, but the particles aren't moving and are in the starting position. https://youtu.be/ZbDjQbl5mzg It seems like some other users have had the same issues in this video's comments.
![image](https://user-images.githubusercontent.com/10787214/83448490-534c3c00-a452-11ea-91c2-7dcabfd498ce.png)

I am on Windows and using Python 3.8.3.

The code is the exact same from the tutorial (with the import in-front):

```
[class MovingCharges(Scene):
CONFIG = {
"plane_kwargs" : {
"color" : RED_B
},
"point_charge_loc" : 0.5*RIGHT-1.5*UP,
}
def construct(self):
plane = NumberPlane(**self.plane_kwargs)
plane.add(plane.get_axis_labels())
self.add(plane)
```

field = VGroup(*[self.calc_field(x*RIGHT+y*UP)
for x in np.arange(-9,9,1)
for y in np.arange(-5,5,1)
])
self.field=field
source_charge = self.Positron().move_to(self.point_charge_loc)
self.play(FadeIn(source_charge))
self.play(ShowCreation(field))
self.moving_charge()

def calc_field(self,point):
x,y = point[:2]
Rx,Ry = self.point_charge_loc[:2]
r = math.sqrt((x-Rx)**2 + (y-Ry)**2)
efield = (point - self.point_charge_loc)/r**3
return Vector(efield).shift(point)

def moving_charge(self):
numb_charges=4
possible_points = [v.get_start() for v in self.field]
points = random.sample(possible_points, numb_charges)
particles = VGroup(*[
self.Positron().move_to(point)
for point in points
])
for particle in particles:
particle.velocity = np.array((0,0,0))

self.play(FadeIn(particles))
self.moving_particles = particles
self.add_foreground_mobjects(self.moving_particles )
self.always_continually_update = True
self.wait(10)

def field_at_point(self,point):
x,y = point[:2]
Rx,Ry = self.point_charge_loc[:2]
r = math.sqrt((x-Rx)**2 + (y-Ry)**2)
efield = (point - self.point_charge_loc)/r**3
return efield

def continual_update(self, *args, **kwargs):
if hasattr(self, "moving_particles"):
dt = self.frame_duration
for p in self.moving_particles:
accel = self.field_at_point(p.get_center())
p.velocity = p.velocity + accel*dt
p.shift(p.velocity*dt)

class Positron(Circle):
CONFIG = {
"radius" : 0.2,
"stroke_width" : 3,
"color" : RED,
"fill_color" : RED,
"fill_opacity" : 0.5,
}
def __init__(self, **kwargs):
Circle.__init__(self, **kwargs)
plus = TexMobject("+")
plus.scale(0.7)
plus.move_to(self)
self.add(plus)
](url)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

O issue é sobre o método continual_update não animando partículas em um campo vetorial. Comece examinando a classe MovingCharges e seu método continual_update. Verifique como a flag always_continually_update é usada no manim codebase. Procure exemplos semelhantes no repositório para ver como as animações são disparadas. Verifique o frame_duration e o loop de atualização. Execute o código fornecido para reproduzir a saída estática.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Domínio
computer-graphics
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.