1 minute read

Appendix i PYTHON SCRIPT FOR THE VOXELIZATION OF SPACES / GEOMETRIES

Next Article
Design Proposal

Design Proposal

import rhinoscriptsyntax as rs import random as r import Rhino.Geometry as rg from math import* voxelGrid = [] newVoxels = []

#OUTPUT a = [] #b = startVoxel() class Voxel: def __init__(self, _loc): self.loc = _loc self.isSorted = False def meshClosestPt(self): meshPt = rs.MeshClosestPoint(inputGeo, self.loc, size) return meshPt def checkIntersection(self): ptx = self.meshClosestPt() if ptx != None: a.append(self.loc) newVoxels.append(self) class Agent: def __init__(self, _loc, _isSorted): self.loc = _loc self.isSorted = False def createVoxels(): for in range(0,gridLength): for in range(0,gridLength): for k in range(0,gridLength): v = rg.Vector3d(i*size, j*size, k*size) vox = Voxel(v) voxelGrid.append(vox) def updateVoxels(): for vox in voxelGrid: vox.checkIntersection() voxelGrid[:] = [] def startVoxel(): stVx = None minDist = 1000000000 for vox in newVoxels: dist = rs.Distance(rg.Point3d(0,0,0),vox.loc) if dist < minDist: minDist = dist stVx = vox.loc return stVx #------------------------------------------------------------------ createVoxels() updateVoxels() startVoxel()

Advertisement

This article is from: