View Single Post
  #1  
Old 02-02-2015, 03:25 AM
seal seal is offline
Member
 
Join Date: Oct 2013
Posts: 8
How to set the color of a group of points depending on their positions very quickly

Hi,

I need to draw around 6000 points that are evenly and randomly distributed in a cubic shape volume. Most of them are white, but those that fall into some randomly located cylinder-shaped volumes (within the cubic volume) should be in other colors (e.g. green or red). I was wondering if there is a way of doing this very quickly rather than using an if-statement for each point as 6000 points may take a very long time to render in such a way?

This is how I draw the points:

Code:
import viz
import numpy as np

viz.go()
number=6000
positions=np.random.uniform(low=-12/2, high=12/2, size=(number,3))

viz.startLayer(viz.POINTS)
viz.pointSize(2)
for i in range(number):	
	viz.vertex(positions[i,:].tolist())
points=viz.endLayer()
In addition, I was wondering if there is a way of drawing all the points together rather than using a for-loop to do it individually?

Any advice would be highly appreciated.
Reply With Quote