コード例 #1
0
ファイル: Visualise.py プロジェクト: wzugang/pvtrace
 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))
コード例 #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)
コード例 #3
0
ファイル: Visualise.py プロジェクト: GuzSku/mcclanahoochie
 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)
コード例 #4
0
ファイル: cube.py プロジェクト: sfaleron/RubiksPy
 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)
コード例 #5
0
ファイル: robots.py プロジェクト: fma38/Py4bot
 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'])
     ))
コード例 #6
0
ファイル: Visualise.py プロジェクト: Javadraees/pvtrace
 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)
コード例 #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)
コード例 #8
0
ファイル: solid.py プロジェクト: agcooke/yeadon
    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)
コード例 #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)
コード例 #10
0
ファイル: Visualise.py プロジェクト: wzugang/pvtrace
 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))
コード例 #11
0
ファイル: Visualise.py プロジェクト: GuzSku/mcclanahoochie
 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)
コード例 #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)
コード例 #13
0
ファイル: Visualise.py プロジェクト: Javadraees/pvtrace
 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)
コード例 #14
0
ファイル: anim.py プロジェクト: lauyader/proyectoPython
    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
コード例 #15
0
ファイル: vec_comb_vpython5.py プロジェクト: orimosenzon/work
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)
コード例 #16
0
ファイル: vec_comb_vpython5.py プロジェクト: orimosenzon/work
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)
コード例 #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)
コード例 #18
0
 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)
コード例 #19
0
 def getBackground(self, **background):
     return convex(pos=list(
         product([-SEMICIRCLE, SEMICIRCLE], [-RIGHT_ANGLE, RIGHT_ANGLE],
                 [-0.1, 0])),
                   **background)
コード例 #20
0
ファイル: drawHexagon.py プロジェクト: DingXuefeng/cpp
#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)
コード例 #21
0
 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)
コード例 #22
0
ファイル: convex-test.py プロジェクト: Griff542/pvtrace
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)
コード例 #23
0
ファイル: convex.py プロジェクト: GadgetSteve/vpython-wx
#!/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)))
コード例 #24
0
ファイル: convex.py プロジェクト: GadgetSteve/vpython-wx
#!/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)))
コード例 #25
0
ファイル: __init__.py プロジェクト: PeterJCLaw/3D-SR-Sim
 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)
コード例 #26
0
ファイル: cube.py プロジェクト: sfaleron/RubiksPy
 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)
コード例 #27
0
ファイル: convex-test.py プロジェクト: taymingyang/pvtrace
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)
コード例 #28
0
ファイル: poly.py プロジェクト: drewsday/Old-Code
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)