Color points by proximity/density?

   15212   10   2
User Avatar
Member
246 posts
Joined: July 2005
Offline
I'm having a “senior moment” and I'm stuck on something that I'm sure is relatively simple - what's the best way to color points or particles based on their density or proximity to each other? I want to increase point color where the area density of the points is higher. Density *$CR, in a nutshell. And as a supplemental question, how best to bake that point cloud information into a texture lookup?
User Avatar
Member
390 posts
Joined: Jan. 2012
Offline
so im not sure if this is the best way, (i dont think its entirely accurate), but i think it works

Attachments:
colorbydensity.hipnc (115.8 KB)

.
User Avatar
Member
509 posts
Joined: July 2005
Offline
point clouds and a while loop.
I use this all the time.

Attachments:
density_vopsop.hip (135.6 KB)

JcN
VisualCortexLab Ltd :: www.visualcortexlab.com
User Avatar
Member
2 posts
Joined: Oct. 2016
Offline
for any one looking at this post in 2019 just put this piece of vex code in a point wrangle its much more efficient.

int pc = pcfind(0,'P',@P,ch('maxdist'),ch('maxpt'));
@Cd = float(len(pc))/ch('maxpt');

explanation on how the code works:
pcfind generates an array with the maximum size of maxpt
len counts how many items there are in the array and divides it by maxpt to get a 0-1 value the float conversion is there as len returns an int and if its not converted the division would return an int giving us a binary 0 or 1 value.



To visualCortexLab if you ever read this thankyou for the inspiration on how to do this.

i dont know if its only for me but the website isent showing the square brakets that are after int pc“square brakets here”
Edited by cabegesoop - March 11, 2019 19:05:33
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
cabegesoop
int pc = pcfind(0,'P',@P,ch('maxdist'),ch('maxpt'));
@Cd = float(len(pc))/ch('maxpt');


nice tip, the simplest solution is usually a better one
User Avatar
Member
36 posts
Joined: Oct. 2018
Offline
cabegesoop
int pc = pcfind(0,'P',@P,ch('maxdist'),ch('maxpt'));
@Cd = float(len(pc))/ch('maxpt');


how do you do this in VOP?
User Avatar
Member
1737 posts
Joined: May 2006
Online
luidox
how do you do this in VOP?

Attachments:
pcfind_vop.PNG (38.8 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
2 posts
Joined: March 2015
Offline
Hello everyone
i wonder how this would work with rbd packed pieces.
how to color them by density.
any hint?

Attachments:
pieceColorbyDensity.jpg (145.0 KB)
piececolorbydensity.hipnc (155.0 KB)

User Avatar
Member
2 posts
Joined: March 2015
Offline
that's what i have so far.
kinda working.
feel like that's not the right way to do this...

Attachments:
PieceDensity.jpg (145.9 KB)
PieceDensity.hipnc (329.0 KB)

User Avatar
Member
1 posts
Joined: Feb. 2017
Offline
Updated for Point Wrangle 2021:


int pc = pcfind(0,'P',v@P,ch('maxdist'),chi('maxpt'));
@Cd = float(len(pc))/chi('maxpt');
User Avatar
Member
32 posts
Joined: Aug. 2011
Offline
I'm not sure if anything has changed, but in 18.5 you need to declare it as an array:

int pc[] = pcfind(0,'P',v@P,ch('maxdist'),chi('maxpt'));
@Cd = float(len(pc))/chi('maxpt'); 

I also find this useful to run in a loop per piece if I'm trying to determine the resolution of each piece of geometry, rather than just the points around it.
Edited by gnisbet - May 27, 2021 04:10:29
  • Quick Links