-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimple_Bresenham.py
More file actions
49 lines (38 loc) · 792 Bytes
/
Simple_Bresenham.py
File metadata and controls
49 lines (38 loc) · 792 Bytes
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
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
x0 = int(input("Enter x1 :"))
y0 = int(input("Enter y1 :"))
x1 = int(input("Enter x2 :"))
y1 = int(input("Enter y2 :"))
print("\n###############")
x = x0
y = y0
dx = x1- x0
dy = y1- y0
print("dx : ",dx,"\ndy : ",dy)
m = dy/dx
print("m : ",m)
e = m - 0.5
print("e : ",e,"\n\n")
#display list points
x_point = []
y_point = []
x_ = []
y_ = []
e_ = []
for i in range(dx):
x_point.append(x)
y_point.append(y)
while(e>0):
y=y+1
e=e-1
y_.append(y)
x=x+1
x_.append(x)
e=e+m
e_.append(e)
print(pd.DataFrame({"X point":x_point,"Y point":y_point,"e":e_, "X":x_,"Y":y_}))
plt.scatter(x_point, y_point, color='red')
plt.plot(x_point, y_point)
plt.show()