Not all points calculating in Point Wrangle (Local Prim Surface Area Calculation)

   1919   3   0
User Avatar
Member
23 posts
Joined: Oct. 2015
Offline
Hi everyone, I'm working on an algorithm that calculates the surface area of nearby primitives and assigns the value to the point. The only thing that doesn't seem to be working is that the point wrangle isn't calculating all the points. Any thoughts or ideas greatly appreciated. Attached a scene file as well but here's the code:


float weight = 1.0;
float primArea = 0.0;


foreach(int j; pointprims(0, @ptnum)){

vector a;
int i = 0;


foreach(int pts; primpoints(0, @primnum)){
a = length(pts);
i++;
}


float A = abs(distance(a,a));
float B = abs(distance(a,a));
float C = abs(distance(a,a));

float s = (A + B + C)/2;

primArea += sqrt(s * (s - A) * (s - B) * (s - C)); //Heron's Formula

}

f@area += weight * primArea;

Edited by trzanko - June 16, 2016 19:11:09

Attachments:
adapt.hiplc (2.7 MB)

Tighe Rzankowski

trzankofx@gmail.com
User Avatar
Member
23 posts
Joined: Oct. 2015
Offline
solved the problem, I didn't need to get length from the nested foreach loop. That part works but now I'm trying to take all these points and fit them into the range between 0 and 1. I'm trying this but its not working.

fit(primArea,min(primArea),max(primArea),0.0,1.0)
Edited by trzanko - June 19, 2016 12:42:11
Tighe Rzankowski

trzankofx@gmail.com
User Avatar
Member
8570 posts
Joined: July 2007
Online
in case you are not doing this purely as a VEX exercise, you can use Measure SOP and promote area to point
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
23 posts
Joined: Oct. 2015
Offline
I was unaware you could do that with a measure SOP, don't know how to yet either(haven't looked into that node). It works already so at this point I might as well compare/contrast it with the measure SOP. I'll reply with my findings. Thanks for the tip Tomas.
Tighe Rzankowski

trzankofx@gmail.com
  • Quick Links