WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to set the color of a group of points depending on their positions very quickly (https://forum.worldviz.com/showthread.php?t=5273)

seal 02-02-2015 03:25 AM

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.

Jeff 02-03-2015 05:16 AM

Do you only need to check if the points are within the cylinder shapes at the time of object creation? If so, that should be fine.


All times are GMT -7. The time now is 07:22 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC