0% found this document useful (0 votes)
5 views4 pages

Animasi Rotasi Bumi dalam GIF

The document contains a Python script that uses Matplotlib to create an animated simulation of a person and the forces acting on them. It includes functions for drawing shapes, arrows, and text, as well as loading an image of a person. The animation visualizes the kinetic energy and motion of the person based on physics principles, and the final output is saved as a GIF.

Uploaded by

FATURRAHMAN 98
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Animasi Rotasi Bumi dalam GIF

The document contains a Python script that uses Matplotlib to create an animated simulation of a person and the forces acting on them. It includes functions for drawing shapes, arrows, and text, as well as loading an image of a person. The animation visualizes the kinetic energy and motion of the person based on physics principles, and the final output is saved as a GIF.

Uploaded by

FATURRAHMAN 98
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NAMA : Muhammad febrian faturrahman

KLS : IK-5

NIM : 0701242114

SIMULASI 3

import [Link] as plt

import [Link] as animation

import [Link] as patches

import [Link] as mpimg

import math

# Muat gambar orang

img = [Link]("[Link]")

# --- Fungsi gambar ---

def Balok(ax, x, y, Lebar, Tinggi, sudut, warna):

rect = [Link]((x, y), Lebar, Tinggi, angle=sudut, color=warna)

ax.add_patch(rect)

def Panah(ax, x0, y0, L, alfa, warna, scale=1):

dx = L * scale * [Link]([Link](alfa))

dy = L * scale * [Link]([Link](alfa))

[Link](x0, y0, dx, dy, head_width=0.5, head_length=1, fc=warna, ec=warna)

def Teks(ax, x0, y0, s, fs, warna):

[Link](x0, y0, s, fontsize=fs, color=warna)

def GambarOrang(ax, x, y, img, width, height):

[Link](img, extent=[x, x + width, y, y + height], zorder=1)


# --- Bagian utama ---

def PhysProb(ax, s, F, theta, HEk, img):

[Link]()

ax.set_xlim((-40, 40))

ax.set_ylim((-20, 20))

ax.set_aspect(1)

[Link]('off')

# Ukuran gambar orang

orang_width = 9

orang_height = 7.5

orang_x = -40 + s + 2.5

orang_y = -10 # supaya nempel di lantai

GambarOrang(ax, orang_x, orang_y, img, orang_width, orang_height)

# Titik tengah gambar orang untuk panah

x_center = orang_x + orang_width / 2

y_center = orang_y + orang_height / 2

# Panah gaya dari tengah gambar

Panah(ax, x0=x_center, y0=y_center, L=F * [Link]([Link](theta)), alfa=90,

warna='gray', scale=0.6)

Panah(ax, x0=x_center, y0=y_center, L=F * [Link]([Link](theta)), alfa=0,

warna='gray', scale=0.6)

Panah(ax, x0=x_center, y0=y_center, L=F, alfa=theta, warna='yellow', scale=0.6)

# Label gaya

Teks(ax, x0=x_center + 3, y0=y_center + 1, s=r'$\theta$=' + str(theta), fs=10, warna='k')


x_label = x_center + 10 * [Link]([Link](theta))

y_label = y_center + 10 * [Link]([Link](theta))

Teks(ax, x0=x_label + 1, y0=y_label, s='F', fs=10, warna='k')

# Lantai dan energi kinetik

Balok(ax, x=-40, y=-10, Lebar=70, Tinggi=2, sudut=0, warna='green')

Balok(ax, x=32, y=-10, Lebar=6, Tinggi=20, sudut=0, warna='k')

Balok(ax, x=32.5, y=-9.5, Lebar=5, Tinggi=22, sudut=0, warna='w')

Balok(ax, x=32.5, y=-9.5, Lebar=5, Tinggi=HEk, sudut=0, warna='r')

Teks(ax, x0=31, y0=12, s=r'$\Delta E_k$', fs=15, warna='k')

# --- Main program ---

fig, ax = [Link]()

M=1

G = 10

sdt = 60

a = G * [Link]([Link](sdt)) / M

t_values, S_values, Ek_values = [], [], []

t=0

while True:

S = 0.5 * a * t ** 2

if S > 65:

break

Ek = G * [Link]([Link](sdt)) * S / (G * [Link]([Link](30)) * 65) * 19

t_values.append(t)

S_values.append(S)

Ek_values.append(Ek)
t += 0.02

def update(frame):

S = S_values[frame]

Ek = Ek_values[frame]

PhysProb(ax, S, F=G, theta=sdt, HEk=Ek, img=img)

ani = [Link](fig, update, frames=len(t_values), interval=20)

# Simpan ke GIF

[Link]('[Link]', writer='pillow', dpi=96)

[Link]()

You might also like