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;
Not all points calculating in Point Wrangle (Local Prim Surface Area Calculation)
1919 3 0- trzanko
- Member
- 23 posts
- Joined: Oct. 2015
- Offline
- trzanko
- 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)
fit(primArea,min(primArea),max(primArea),0.0,1.0)
Edited by trzanko - June 19, 2016 12:42:11
Tighe Rzankowski
trzankofx@gmail.com
trzankofx@gmail.com
- tamte
- Member
- 8570 posts
- Joined: July 2007
- Online
- trzanko
- Member
- 23 posts
- Joined: Oct. 2015
- Offline
-
- Quick Links