migrated code to public repository
This commit is contained in:
parent
a7df82d7a4
commit
f34dc653e5
233 changed files with 16279 additions and 186 deletions
46
code/util.py
Normal file
46
code/util.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
import visual as vs
|
||||
# from visual import vector as v
|
||||
from vector import Vector as v
|
||||
import wx
|
||||
|
||||
def drawAxes(frame, color, size, position):
|
||||
# directions = (vs.vector(size, 0, 0),
|
||||
# vs.vector(0, size, 0),
|
||||
# vs.vector(0, 0, size))
|
||||
directions = (vs.vector(size, 0, 0),
|
||||
vs.vector(0, size, 0),
|
||||
vs.vector(0, 0, size))
|
||||
labels = 'X', 'Y', 'Z'
|
||||
origin = vs.vector(position)
|
||||
for i in xrange(3):
|
||||
# vs.curve(frame=frame, color=color,
|
||||
# pos=[origin, origin+directions[i]])
|
||||
vs.arrow(frame=frame, color=color,
|
||||
pos=origin, axis=directions[i], shaftwidth=0.5)
|
||||
vs.label(frame=frame, color=color, box=False,
|
||||
text=labels[i],
|
||||
pos=origin+directions[i])
|
||||
|
||||
# def wCoords(x, y, z):
|
||||
# return wCoords(v(x, y, z))
|
||||
# def wCoords(p):
|
||||
# return v(-p.x, p.y, -p.z)
|
||||
|
||||
def drawLine(frame, position, length, direction, color = vs.color.white):
|
||||
'''
|
||||
Draws a straight line from given position, with given length and direction
|
||||
(all are relative to given frame)
|
||||
'''
|
||||
return vs.curve(frame=frame, pos=[v(position), v(position)+v(direction).norm()*length], color = color)
|
||||
|
||||
# def reDrawLine(line, position, length, direction):
|
||||
# line.pos = [position, position+direction.norm()*length]
|
||||
|
||||
def Button(label, x, y, func, size, pan):
|
||||
btn = wx.Button(pan, label=label, pos=(x, y), size=size)
|
||||
btn.Bind(wx.EVT_BUTTON, func)
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue