def agente_distance(destinos, protocolo):
    resultados = []
    for des in destinos:
        i = 0
        destino_resul = {}
        destino_resul["nombre"] = des["nombre"]
        destino_resul["vars"] = []
        for var in des["vars"]:
            resul = {}
            resul["nombre_del_destino"] = des["nombre"]
            resul["nombre"] = (var["nombre"])
            resul["tipo"] = (var["tipo"])
            if (var["tipo"] == "float" or var["tipo"] == "int"):
                p = r3.Line3D(r3.Point3D(var["data"]),
                              r3.Point3D(protocolo[i][3]))
                d = p.Distans()
                resul["result"] = (d)
                print d
                raw_input("presiona una tecla para continuar...")
            if (var["tipo"] == "string"):
                resul["result"] = []
                for data in protocolo[i]["optimo"]:
                    if (var["data"] == data):
                        resul["result"].apped(data)

            destino_resul["vars"].append(resul)
            i += 1
        resultados.append(destino_resul)
    return resultados
Exemple #2
0
    def sides(self, middle, sideLength):
        half = sideLength / 2.0

        line = line3D.Line3D(
            point3D.Point3D(middle.x - half, middle.y + half, middle.z - half),
            point3D.Point3D(middle.x - half, middle.y - half, middle.z - half))
        self.lines.append(line)

        line = line3D.Line3D(
            point3D.Point3D(middle.x - half, middle.y + half, middle.z + half),
            point3D.Point3D(middle.x - half, middle.y - half, middle.z + half))
        self.lines.append(line)

        line = line3D.Line3D(
            point3D.Point3D(middle.x + half, middle.y + half, middle.z - half),
            point3D.Point3D(middle.x + half, middle.y - half, middle.z - half))
        self.lines.append(line)

        line = line3D.Line3D(
            point3D.Point3D(middle.x + half, middle.y + half, middle.z + half),
            point3D.Point3D(middle.x + half, middle.y - half, middle.z + half))
        self.lines.append(line)
Exemple #3
0
class VirtualWorld:
	objects = []
	virtualCamera = virtualCamera.VirtualCamera(point3D.Point3D(0.0, 0.0, 0.0), 0.5, 2.0, 2.0)
		
	def addElement(self, obj):
		self.objects.append(obj)
		
	def generate2D(self):
		return self.virtualCamera.calculate(self.objects)
	
	def move(self, direction):
		for obj in self.objects:
			obj.move(direction)

	def rotate(self, direction):
		for obj in self.objects:
			obj.rotate(direction)

	def zoomIn(self):
		self.virtualCamera.zoomIn()

	def zoomOut(self):
		self.virtualCamera.zoomOut()
Exemple #4
0
driver = ogr.GetDriverByName('ESRI Shapefile')

# 0 means read-only. 1 means writeable.
dataSource = driver.Open(daShapefile, 0)

# Check to see if shapefile is found.
if dataSource is None:
    print('Could not open %s' % (daShapefile))
else:
    print('Opened %s' % (daShapefile))
    layer = dataSource.GetLayer()
    featureCount = layer.GetFeatureCount()
    print("Number of features in %s: %d" %
          (os.path.basename(daShapefile), featureCount))
    for feature in layer:
        # We have multi-polygon
        geom = feature.GetGeometryRef()
        print(geom.GetGeometryName())
        trs = []
        for i in xrange(geom.GetGeometryCount()):
            geomTemp = geom.GetGeometryRef(i)
            ring = geomTemp.GetGeometryRef(0)
            points = ring.GetPointCount()
            # Normally only 4 points for closed triangles
            pts = []
            for p in xrange(points):
                x, y, z = ring.GetPoint(p)
                pts.append(pt3D.Point3D(x, y, z))
            trs.append(tr3D.Triangle3D(0, pts[0], pts[1], pts[2]))
trs[0].printEl()
Exemple #5
0
import directionEnum

from pygame.locals import *

pygame.init()

windowHeight = 600
windowWidth = 600

window = pygame.display.set_mode((windowWidth, windowHeight))

GREEN = (20,220,10)

virtualWorld = virtualWorld.VirtualWorld()

cube1 = cube.Cube(point3D.Point3D(-2.0, 0.0, 10.0), 3.0)
cube2 = cube.Cube(point3D.Point3D(2.0, 0.0, 10.0), 3.0)
cube3 = cube.Cube(point3D.Point3D(-2.0, 0.0, 5.0), 3.0)
cube4 = cube.Cube(point3D.Point3D(2.0, 0.0, 5.0), 3.0)

virtualWorld.addElement(cube1)
virtualWorld.addElement(cube2)
virtualWorld.addElement(cube3)
virtualWorld.addElement(cube4)

def scale(lines):
	cameraHeight = virtualWorld.virtualCamera.height
	cameraWidth = virtualWorld.virtualCamera.width

	heightScale = windowHeight / cameraHeight
	widthScale = windowWidth / cameraWidth
 def __init__(self, ID=0, point1=None, point2=None, point3=None):
     self.id = ID
     self.point1 = point1 or pt3D.Point3D()  # (0,0,0) by default
     self.point2 = point2 or pt3D.Point3D()  # (0,0,0) by default
     self.point2 = point2 or pt3D.Point3D()  # (0,0,0) by default