Commit f2cf4524 authored by Moritz's avatar Moritz

PointCloudToGridMapper: when computing direction vector for gridpoint the...

PointCloudToGridMapper: when computing direction vector for gridpoint the average of the direction vectors is now used
parent e7283cd1
......@@ -260,20 +260,17 @@ namespace Teamproject {
Vector3 pointPos = new Vector3(x * gridStepSize, y * gridStepSize, z * gridStepSize);
if (nei[x, y, z] != null) {
//find nearest neighbor
int nearestIndex = 0;
float nearestDist = Vector3.Distance(pointPos, nei[x, y, z][0].Position);
for (int i = 1; i < nei[x, y, z].Count; i++) {
var dist = Vector3.Distance(pointPos, nei[x, y, z][i].Position);
if (dist < nearestDist) {
nearestDist = dist; //dist = nearestDist; //war wohl falsch
nearestIndex = i;
}
}
directionGrid[x, y, z] = nei[x, y, z][nearestIndex].Direction;
info[x, y, z] = 0;//nei[x, y, z][nearestIndex].Type;
//2. approach
Vector3 meanDirection = Vector3.zero;
foreach(PCachePoint currentNeighbor in nei[x, y, z])
meanDirection += currentNeighbor.Direction;
meanDirection /= nei[x, y, z].Count;
directionGrid[x, y, z] = meanDirection;
info[x, y, z] = 0;
}
else {
directionGrid[x, y, z] = Vector3.zero;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment