Color points by proximity/density?
17271 10 3-
- stu
- 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?
-
- zdimaria
- Member
- 390 posts
- Joined: Jan. 2012
- Offline
-
- VisualCortexLab
- Member
- 509 posts
- Joined: July 2005
- Offline
point clouds and a while loop.
I use this all the time.
I use this all the time.
JcN
VisualCortexLab Ltd :: www.visualcortexlab.com
VisualCortexLab Ltd :: www.visualcortexlab.com
-
- cabegesoop
- 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”
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
-
- ouroboros1221
- Member
- 79 posts
- Joined: Feb. 2016
- Offline
-
- luidox
- Member
- 36 posts
- Joined: Oct. 2018
- Offline
-
- mestela
- Member
- 1834 posts
- Joined: May 2006
- Offline
-
- dubcut
- Member
- 2 posts
- Joined: March 2015
- Offline
-
- dubcut
- Member
- 2 posts
- Joined: March 2015
- Offline
-
- BRYANSMOSH
- Member
- 1 posts
- Joined: Feb. 2017
- Offline
-
- gnisbet
- 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:
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.
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