-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcelclothoid.py
46 lines (38 loc) · 1.08 KB
/
excelclothoid.py
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
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Parametre t'nin aralığı ve çözünürlüğü
t = np.linspace(0, 1, 100)
# Fonksiyonlar
x = np.cumsum(np.cos(t**2) * (t[1] - t[0])) # dx = cos(t^2) dt'nin integrali
y = np.cumsum(np.sin(t**2) * (t[1] - t[0])) # dy = sin(t^2) dt'nin integrali
kappa = 2 * t # Eğrilik
# Verileri bir DataFrame'e kaydet
data = pd.DataFrame({
't': t,
'x': x,
'y': y,
'kappa': kappa
})
# Veriyi Excel dosyasına yaz
excel_file = 'curve_and_curvature.xlsx'
data.to_excel(excel_file, index=False)
print(f"Veriler '{excel_file}' dosyasına kaydedildi.")
# Grafik çizimi
fig, axs = plt.subplots(2, 1, figsize=(8, 10))
# Eğri çizimi
axs[0].plot(x, y, label='Eğri: (x(t), y(t))')
axs[0].set_title('Eğri Çizimi')
axs[0].set_xlabel('x')
axs[0].set_ylabel('y')
axs[0].legend()
axs[0].grid()
# Eğrilik grafiği
axs[1].plot(t, kappa, label='Eğrilik: κ(t) = 2t', color='r')
axs[1].set_title('Eğrilik Fonksiyonu')
axs[1].set_xlabel('t')
axs[1].set_ylabel('κ(t)')
axs[1].legend()
axs[1].grid()
plt.tight_layout()
plt.show()