Created
April 4, 2014 06:36
-
-
Save twatteyne/9969311 to your computer and use it in GitHub Desktop.
Dynamic VPython-based visualization of a vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import visual | |
MAXDIFF = 0.05 | |
class ArrowCoords(object): | |
x = random.random() | |
y = random.random() | |
z = random.random() | |
def get(self): | |
self.x += -MAXDIFF/2+MAXDIFF*random.random() | |
self.y += -MAXDIFF/2+MAXDIFF*random.random() | |
self.z += -MAXDIFF/2+MAXDIFF*random.random() | |
return (self.x,self.y,self.z) | |
#============================ main ============================================ | |
def main(): | |
coords = ArrowCoords() | |
arr = visual.arrow( | |
pos = (0,0,0), | |
color = visual.color.green, | |
material = visual.materials.emissive, | |
) | |
while True: | |
visual.rate(100) | |
arr.axis = coords.get() | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment