Skip to content

Instantly share code, notes, and snippets.

@aneasystone
Created March 12, 2018 14:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aneasystone/52594ebf2e607c4085024ebd06b9cd9b to your computer and use it in GitHub Desktop.
Save aneasystone/52594ebf2e607c4085024ebd06b9cd9b to your computer and use it in GitHub Desktop.
import pylab
import bs4
def get_mcd_content():
path = 'C:/Users/aneasystone/Desktop/11.mcd'
mcd = ''
with open(path, 'rb') as file:
mcd = file.read()
return str(mcd)
def parse_mcd_content(mcd):
print(mcd)
soup = bs4.BeautifulSoup(mcd, 'lxml')
print(soup)
events = soup.select('mouseevents')
print(len(events))
results = []
for event in events:
pos = event.find('d3p1:x')
print(pos.text)
results.append(int(pos.text))
return results
def get_track(distance):
track = [0]
current = 0
mid = distance * 4 / 5
t = 0.2
v = 0
while current < distance:
if current < mid:
a = 2
else:
a = -3
v0 = v
v = v0 + a * t
move = v0 * t + 1 / 2 * a * t * t
current += move
track.append(track[len(track)-1] + round(move))
return track
# content = get_mcd_content()
# results = parse_mcd_content(content)
# x = range(0, len(results))
# pylab.plot(x, results, 'r')
# pylab.show()
# results = get_track(40)
results = [0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,15,17,19,21,23,25,27,29,31,33,35,37,40,43,46,49,52,55,58,61,64,67,70,73,76,80,84,88,92,96,100,104,107,110,113]
print(results)
x = range(0, len(results))
pylab.plot(x, results, 'r')
pylab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment