Exemplo n.º 1
0
 def addPolygon(self, polygon, colour=None, opacity=1.):
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(polygon, Polygon):
         if colour == None:
             visual.convex(pos=polygon.pts, color=norm([0.1,0.1,0.1]))
         else:
             visual.convex(pos=polygon.pts, color=norm(colour))
Exemplo n.º 2
0
 def addPolygon(self, polygon, colour=None, opacity=1., material=visual.materials.plastic):
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(polygon, geo.Polygon):
         if colour == None:
             visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             visual.convex(pos=polygon.pts, color=geo.norm(colour), material=material)
Exemplo n.º 3
0
 def addPolygon(self, polygon, colour=None):
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(polygon, geo.Polygon):
         if colour == None:
             visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=visual.materials.plastic)
         else:
             visual.convex(pos=convex.points, color=geo.norm(colour), opacity=0.5)
Exemplo n.º 4
0
 def __init__(self, parent, pos, size, color1):
    frame.__init__(self, frame=parent, pos=pos)
    convex(frame=self, pos = (
       (-size/2, -size/2, 0),
       ( size/2, -size/2, 0),
       (-size/2,  size/2, 0),
       ( size/2,  size/2, 0) ),
       color=color1)
Exemplo n.º 5
0
 def _build3D(self):
     visual.convex(frame=self, axis=(0, 1, 0), pos=(
         (settings.LEGS_ORIGIN['RF']['x'], 0, settings.LEGS_ORIGIN['RF']['y']),
         (settings.LEGS_ORIGIN['RM']['x'], 0, settings.LEGS_ORIGIN['RM']['y']),
         (settings.LEGS_ORIGIN['RR']['x'], 0, settings.LEGS_ORIGIN['RR']['y']),
         (settings.LEGS_ORIGIN['LR']['x'], 0, settings.LEGS_ORIGIN['LR']['y']),
         (settings.LEGS_ORIGIN['LM']['x'], 0, settings.LEGS_ORIGIN['LM']['y']),
         (settings.LEGS_ORIGIN['LF']['x'], 0, settings.LEGS_ORIGIN['LF']['y'])
     ))
Exemplo n.º 6
0
 def addPolygon(self, polygon, colour=None, opacity=1., material=None):
     if not VISUAL_INSTALLED:
         return
     if isinstance(polygon, geo.Polygon):
         if material is None:
             material = visual.materials.plastic
         if colour is None:
             visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             visual.convex(pos=polygon.pts, color=geo.norm(colour), material=material)
Exemplo n.º 7
0
 def addPolygon(self, polygon, colour=None, opacity=1., material=None):
     if not VISUAL_INSTALLED:
         return
     if isinstance(polygon, geo.Polygon):
         if material is None:
             material = visual.materials.plastic
         if colour == None:
             visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             visual.convex(pos=polygon.pts, color=geo.norm(colour), material=material)
Exemplo n.º 8
0
    def draw_visual(self, c):
        '''Draws the stadium in 3D in a VPython window. Only one line of code!

        Parameters
        ----------
        c : tuple (3,)
            Color as an rgb tuple, with values between 0 and 1.

        '''
        vis.convex(pos = self.make_pos_visual(), color=c)
Exemplo n.º 9
0
 def addConvex(self, convex, colour=None, opacity=1., material=visual.materials.plastic):
     """docstring for addConvex"""
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(convex, geo.Convex):
         if colour == None:
             print "Color is none"
             visual.convex(pos=convex.points, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             #import pdb; pdb.set_trace()
             print "Colour is", geo.norm(colour)
             visual.convex(pos=convex.points, color=geo.norm(colour), material=material)
Exemplo n.º 10
0
 def addConvex(self, convex, colour=None, opacity=1.):
     """docstring for addConvex"""
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(convex, Convex):
         if colour == None:
             print("Color is none")
             visual.convex(pos=convex.points, color=norm([0.1,0.1,0.1]))
         else:
             #import pdb; pdb.set_trace()
             print("Colour is", norm(colour))
             visual.convex(pos=convex.points, color=norm(colour))
Exemplo n.º 11
0
 def addConvex(self, convex, colour=None):
     """docstring for addConvex"""
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(convex, geo.Convex):
         if colour == None:
             print "Color is none"
             visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=visual.materials.plastic)
         else:
             import pdb; pdb.set_trace()
             print "Colour is", geo.norm(colour)
             visual.convex(pos=convex.points, color=geo.norm(colour), material=visual.materials.plastic)
Exemplo n.º 12
0
 def addConvex(self, convex, colour=None, opacity=1., material=None):
     """docstring for addConvex"""
     if not VISUAL_INSTALLED:
         return
     if isinstance(convex, geo.Convex):
         if material is None:
             material = visual.materials.plastic
         if colour == None:
             print "Color is none"
             visual.convex(pos=convex.points, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             #import pdb; pdb.set_trace()
             print "Colour is", geo.norm(colour)
             visual.convex(pos=convex.points, color=geo.norm(colour), material=material)
Exemplo n.º 13
0
 def addConvex(self, convex, colour=None, opacity=1., material=None):
     """docstring for addConvex"""
     if not VISUAL_INSTALLED:
         return
     if isinstance(convex, geo.Convex):
         if material is None:
             material = visual.materials.plastic
         if colour is None:
             print("Color is none")
             visual.convex(pos=convex.points, color=geo.norm([0.1,0.1,0.1]), material=material)
         else:
             #import pdb; pdb.set_trace()
             print("Colour is", geo.norm(colour))
             visual.convex(pos=convex.points, color=geo.norm(colour), material=material)
Exemplo n.º 14
0
    def addcar(self, pos, color=v.color.green, name="v"):
        # Creating car 
        car = v.frame()
        car.start = pos
        car.pos = car.start
        car.vector = v.vector(0.05, 0, 0) 
        car.color = color
        car.colorori = car.color

        body = v.box(frame = car, pos = (0,0,0), size = (2.4*self.thk, 0.6*self.thk, 1.4*self.thk), color = car.colorori) 
        wheel1 = v.cylinder(frame=car, pos=(0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6)) 
        wheel2 = v.cylinder(frame=car, pos=(-0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6)) 
        head = v.convex(frame=car, color=car.colorori)
        head.append(pos=v.vector(0.6, 0.3, -0.7)*self.thk)
        head.append(pos=v.vector(0.6, 0.3, 0.7)*self.thk)
        head.append(pos=v.vector(-1.2, 0.3, -0.7)*self.thk)
        head.append(pos=v.vector(-1.2, 0.3, 0.7)*self.thk)
        head.append(pos=v.vector(0.4, 0.7, -0.6)*self.thk)
        head.append(pos=v.vector(0.4, 0.7, 0.6)*self.thk)
        head.append(pos=v.vector(-0.8, 0.7, -0.6)*self.thk)
        head.append(pos=v.vector(-0.8, 0.7, 0.6)*self.thk)

        # Creating Label
        car.vlabel = v.label(justify='center', pos=car.pos, xoffset=3*self.thk, yoffset=39*self.thk, space=3*self.thk, text=name,height=15, line=0,border=3)

        self.cars[name] = car
        self.labels[name] = car.vlabel
Exemplo n.º 15
0
def update_convex():
    if not showSpan:
        return
    global current_span
    current_span.visible = 0

    poss = [orig]
    sum = visual.vector(orig)

    vecs = map(lambda i: vectors[i].axis * span_fact, selected)

    poss = all_conv_comb(vecs)

    current_span = visual.convex(pos=poss, color=span_color)
Exemplo n.º 16
0
def update_convex():
    if not showSpan:
        return 
    global current_span
    current_span.visible = 0 

    poss = [orig] 
    sum = visual.vector(orig)

    vecs = map(lambda i:vectors[i].axis * span_fact, selected)

    poss = all_conv_comb(vecs)

    current_span = visual.convex(pos=poss, color = span_color)
Exemplo n.º 17
0
 def MakeMeshObject(self):
     """Generate a VPython display object based on the tri-mesh properties."""
     #return visual.faces(pos=self._Verticies, colors=self._Colors, normals=self._Normals)
     return visual.convex(pos=self._verticies)
 def show(self, window):
     for indices in self.index_lists:
         points = []
         for index in indices:
             points.append(tuple(self.points[index]))
         visual.convex(pos = points, color = window.foreground)
Exemplo n.º 19
0
 def getBackground(self, **background):
     return convex(pos=list(
         product([-SEMICIRCLE, SEMICIRCLE], [-RIGHT_ANGLE, RIGHT_ANGLE],
                 [-0.1, 0])),
                   **background)
Exemplo n.º 20
0
#z=roundarray(z,roundnum)
#x=xx
#y=yy
#z=zz

r1data=[(0,(0,0,1)),(np.pi/2,(0,0,1)),(np.pi/2,(0,0,1))]
r2data=[(0,(0,0,1)),(np.pi/2,(1,0,0)),(np.pi/2,(0,1,0))]
lframe = vs.frame()
for obj in vs.scene.lights:
    if isinstance(obj, vs.distant_light):
        obj.frame = lframe # put distant lights in a frame
old = vs.vector(vs.scene.forward) # keep a copy of the old forward

for k in range(len(r1data)):
  for i in range(len(x)):
    hexagon = vs.convex(color=(0.7,0.7,0.7))
    L = []
    r=0.264*(2*3**0.5+1)
    rr=r/3**0.5*2
    h=0.254+0.2
    rru=rr/R*(R-h)
    theta=thetaList[i]
    phi=phiList[i]
    ex=vs.vector(1,0,0)
    ey=vs.vector(0,1,0)
    ez=vs.vector(0,0,1)
    ex=ex.rotate(angle=vs.deg2rad(90)+phi,axis=ez)
    ey=ey.rotate(angle=vs.deg2rad(90)+phi,axis=ez)
    ey=ey.rotate(angle=vs.deg2rad(180)+theta,axis=ex)
    ez=ez.rotate(angle=vs.deg2rad(180)+theta,axis=ex)
    ex=ex.rotate(angle=vs.deg2rad(-90),axis=ez)
 def show(self, window):
     for indices in self.index_lists:
         points = []
         for index in indices:
             points.append(tuple(self.points[index]))
         visual.convex(pos = points, color = window.foreground)
Exemplo n.º 22
0
from __future__ import division
import numpy as np
from pvtrace import transformations as tf
from pvtrace import *
import visual as v

points = [(0,0,0),(0.05,0,0),(0,0.05,0),(0.05,0.05,0),(0.025,0.025,.05)]
convex = Convex(points)

#convex = Box(origin=(0,0,0), extent=(0.05,0.05,0.05))

print convex.on_surface((0,0.01,0))

ray = Ray(position=(0.045,0.019,-0.01), direction=norm((0,0,1)))
print convex.intersection(ray)

v.convex(pos=points)
v.cylinder(pos=ray.position, axis=ray.direction, radius=0.0001)
Exemplo n.º 23
0
#!/usr/bin/env python
#coding:utf-8
""" Example of drawing and modifying shapes."""
from __future__ import print_function, division
import visual as vp
from random import uniform

print(__doc__)
# David Scherer

vp.scene.range = 3
PI = vp.pi
A = vp.convex(color=(0.5, 0, 0))
B = vp.convex(color=(0, 0.5, 0))
C = vp.convex(color=(0, 0, 0.5))
D = vp.convex(color=(0.5, 0, 0.5))
E = vp.convex(color=(0.5, 0.5, 0))
F = vp.convex(color=(0, 0.5, 0.5))

# circle
T = vp.arange(0, 2 * PI, 0.1)
E.pos = vp.transpose((vp.sin(T), vp.cos(T) + 2, 0 * T))

# triangle
T = vp.arange(0, 2 * PI, 2 * PI / 3)
F.pos = vp.transpose((vp.sin(T) - 2, vp.cos(T) + 2, 0 * T))

# disk
for T in vp.arange(0, 2 * PI, 0.1):
    A.append(pos=(vp.cos(T), 0, vp.sin(T)))
    A.append(pos=(vp.cos(T), 0.2, vp.sin(T)))
Exemplo n.º 24
0
#!/usr/bin/env python
#coding:utf-8
""" Example of drawing and modifying shapes."""
from __future__ import print_function, division
import visual as vp
from random import uniform

print(__doc__)
# David Scherer

vp.scene.range = 3
PI = vp.pi
A = vp.convex(color=(0.5, 0, 0))
B = vp.convex(color=(0, 0.5, 0))
C = vp.convex(color=(0, 0, 0.5))
D = vp.convex(color=(0.5, 0, 0.5))
E = vp.convex(color=(0.5, 0.5, 0))
F = vp.convex(color=(0, 0.5, 0.5))

# circle
T = vp.arange(0, 2*PI, 0.1)
E.pos = vp.transpose((vp.sin(T), vp.cos(T)+2, 0*T))

# triangle
T = vp.arange(0, 2*PI, 2*PI/3)
F.pos = vp.transpose((vp.sin(T)-2, vp.cos(T)+2, 0*T))

# disk
for T in vp.arange(0, 2*PI, 0.1):
    A.append(pos=(vp.cos(T), 0, vp.sin(T)))
    A.append(pos=(vp.cos(T), 0.2, vp.sin(T)))
Exemplo n.º 25
0
 def MakeMeshObject(self):
     """Generate a VPython display object based on the tri-mesh properties."""
     #return visual.faces(pos=self._Verticies, colors=self._Colors, normals=self._Normals)
     return visual.convex(pos=self._verticies)
Exemplo n.º 26
0
 def __init__(self, parent, pos, size, color1):
     frame.__init__(self, frame=parent, pos=pos)
     convex(frame=self,
            pos=((-size / 2, -size / 2, 0), (size / 2, -size / 2, 0),
                 (-size / 2, size / 2, 0), (size / 2, size / 2, 0)),
            color=color1)
Exemplo n.º 27
0
from __future__ import division
import numpy as np
from pvtrace import transformations as tf
from pvtrace import *
import visual as v

points = [(0, 0, 0), (0.05, 0, 0), (0, 0.05, 0), (0.05, 0.05, 0),
          (0.025, 0.025, .05)]
convex = Convex(points)

#convex = Box(origin=(0,0,0), extent=(0.05,0.05,0.05))

print convex.on_surface((0, 0.01, 0))

ray = Ray(position=(0.045, 0.019, -0.01), direction=norm((0, 0, 1)))
print convex.intersection(ray)

v.convex(pos=points)
v.cylinder(pos=ray.position, axis=ray.direction, radius=0.0001)
Exemplo n.º 28
0
from visual import frame, rate, convex

points = ( (0, 0.771, 0.257), (0.727, 0.257, -0.257), (
                        0.364, 0.514, -0.514), (0, 0.257, 0.771), (
                        -0.364, 0.514, 0.514), (-0.364, -0.514, -0.514), (
                        0, -0.771, 0.257), (-0.727, -0.257, 0.257), (
                        0.364, 0.514, 0.514), (0.727, -0.257, -0.257), (
                        0.727, 0.257, 0.257), (0, 0.257, -0.771), (
                        0.727, -0.257, 0.257), (-0.364, 0.514, -0.514), (
                        -0.727, 0.257, 0.257), (0.364, -0.514, -0.514), (
                        -0.727, -0.257, -0.257), (0, 0.771, -0.257), (
                        0, -0.771, -0.257), (-0.727, 0.257, -0.257), (
                        0, -0.257, -0.771), (0.364, -0.514, 0.514), (
                        -0.364, -0.514, 0.514), (0, -0.257, 0.771), )

f = frame()
a = convex(color = (0.9,0.1,0.8), frame = f)

for t in points:
    a.append(pos = t)

a.display.autoscale = 0

while 1:
    rate(100)
    f.rotate(angle=0.01)