本文整理汇总了C#中Voxel.GetIndexFromPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Voxel.GetIndexFromPosition方法的具体用法?C# Voxel.GetIndexFromPosition怎么用?C# Voxel.GetIndexFromPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voxel
的用法示例。
在下文中一共展示了Voxel.GetIndexFromPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointToVoxel
void PointToVoxel(List<Point> basedata)
{
double maxX = Math.Ceiling(basedata.Max(p => p.GetVector3().x));
double minX = Math.Floor(basedata.Min(p => p.GetVector3().x));
double maxY = Math.Ceiling(basedata.Max(p => p.GetVector3().y));
double minY = Math.Floor(basedata.Min(p => p.GetVector3().y));
double maxZ = Math.Ceiling(basedata.Max(p => p.GetVector3().z));
double minZ = Math.Floor(basedata.Min(p => p.GetVector3().z));
//1 = 1メートル
double delta = 0.05;
int inverse = (int)(1 / delta);
int width = (int)((maxX - minX) * inverse);
int height = (int)((maxY - minY) * inverse);
int depth = (int)((maxZ - minZ) * inverse);
Voxel = new Voxel<List<Point>>(width, height, depth, minX, minY, minZ, delta);
AnotherVoxel = new Voxel<List<Point>>(width, height, depth, minX - delta * 0.5, minY - delta * 0.5, minZ - delta * 0.5, delta);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
for (int k = 0; k < depth; k++) {
Voxel[i, j, k] = new List<Point>();
AnotherVoxel[i, j, k] = new List<Point>();
}
}
}
foreach (var d in basedata) {
var indexVec = Voxel.GetIndexFromPosition(d.GetVector3());
if (indexVec.x == Voxel.Width) indexVec.x -= 1;
if (indexVec.y == Voxel.Height) indexVec.y -= 1;
if (indexVec.z == Voxel.Depth) indexVec.z -= 1;
Voxel[(int)indexVec.x, (int)indexVec.y, (int)indexVec.z].Add(d);
var aindex = AnotherVoxel.GetIndexFromPosition(d.GetVector3());
if (aindex.x == AnotherVoxel.Width) aindex.x -= 1;
if (aindex.y == AnotherVoxel.Height) aindex.y -= 1;
if (aindex.z == AnotherVoxel.Depth) aindex.z -= 1;
AnotherVoxel[(int)indexVec.x, (int)indexVec.y, (int)indexVec.z].Add(d);
}
}