当前位置: 首页>>代码示例>>C#>>正文


C# AABB.ClosestPt方法代码示例

本文整理汇总了C#中AABB.ClosestPt方法的典型用法代码示例。如果您正苦于以下问题:C# AABB.ClosestPt方法的具体用法?C# AABB.ClosestPt怎么用?C# AABB.ClosestPt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AABB的用法示例。


在下文中一共展示了AABB.ClosestPt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Partition


//.........这里部分代码省略.........
                                Vector3f V = new Vector3f((float)(Map_Mesh.Normals[i].X * increment * .5), (float)(Map_Mesh.Normals[i].Y * increment * .5), (float)(Map_Mesh.Normals[i].Z * increment * .5));

                                p = new Hare.Geometry.Point(Map_Mesh.Vertices[i].X+ V.X, Map_Mesh.Vertices[i].Y + V.Y, Map_Mesh.Vertices[i].Z+ V.Z);
                                Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p), _Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < Map_Mesh.Faces.Count; i++)
                            {
                                Point3f center = new Point3f();
                                center.X = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].X + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].X + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].X;
                                center.Y = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Y + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Y + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Y;
                                center.Z = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Z + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Z + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Z;

                                if (Map_Mesh.Faces[i].IsQuad)
                                {
                                    center.X += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].X;
                                    center.Y += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Y;
                                    center.Z += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Z;
                                    center.X /= 4; center.Y /= 4; center.Z /= 4;
                                }
                                else { center.X /= 3; center.Y /= 3; center.Z /= 3; }

                                Vector3f V = new Vector3f((float)(Map_Mesh.FaceNormals[i].X * increment * .5), (float)(Map_Mesh.FaceNormals[i].Y * increment * .5), (float)(Map_Mesh.FaceNormals[i].Z * increment * .5));

                                p = new Hare.Geometry.Point(center.X + V.X, center.Y + V.Y, center.Z + V.Z);
                                Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p),_Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional);
                            }
                        }

                        if (Mesh_Offset) for (int i = 0; i < Map_Mesh.Vertices.Count; i++)
                        {
                            Vector3f V = Map_Mesh.Normals[i];
                            Map_Mesh.Vertices[i] = new Point3f(Map_Mesh.Vertices[i].X + (float)V.X,
                            Map_Mesh.Vertices[i].Y + (float)V.Y,
                            Map_Mesh.Vertices[i].Z + (float)V.Z);
                        }
                    }
                }
                else 
                {
                    for (int i = 0; i < Map_Mesh.Vertices.Count; i++)
                    {
                        Hare.Geometry.Point V = new Hare.Geometry.Point(0, 0, increment * .5);
                        Hare.Geometry.Point p = new Hare.Geometry.Point(Map_Mesh.Vertices[i].X, Map_Mesh.Vertices[i].Y, Map_Mesh.Vertices[i].Z);
                        Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Rho(p), _Sc.Sound_speed(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional);
                    }
                }

                foreach (Spherical_Receiver R in Rec_List)
                {
                    //Find max and min bounds of all spheres...
                    if ((R.H_Origin.x + (increment * .5)) > Max.x) Max.x = R.H_Origin.x + (increment * .5);
                    if ((R.H_Origin.y + (increment * .5)) > Max.y) Max.y = R.H_Origin.y + (increment * .5);
                    if ((R.H_Origin.z + (increment * .5)) > Max.z) Max.z = R.H_Origin.z + (increment * .5);
                    if ((R.H_Origin.x - (increment * .5)) < Min.x) Min.x = R.H_Origin.x - (increment * .5);
                    if ((R.H_Origin.y - (increment * .5)) < Min.y) Min.y = R.H_Origin.y - (increment * .5);
                    if ((R.H_Origin.z - (increment * .5)) < Min.z) Min.z = R.H_Origin.z - (increment * .5);
                }
                OBox = new AABB(Min, Max);

                //Divide the Min and Max into separate sub-voxels...
                VoxelCtX = (int)Math.Ceiling((OBox.Max_PT.x - OBox.Min_PT.x) / (increment * 4));
                VoxelCtY = (int)Math.Ceiling((OBox.Max_PT.y - OBox.Min_PT.y) / (increment * 4));
                VoxelCtZ = (int)Math.Ceiling((OBox.Max_PT.z - OBox.Min_PT.z) / (increment * 2.5));

                Voxels = new AABB[VoxelCtX, VoxelCtY, VoxelCtZ];
                Voxel_Inv = new List<int>[VoxelCtX, VoxelCtY, VoxelCtZ];

                BoxDims = (Max - Min);
                VoxelDims = new Hare.Geometry.Point(BoxDims.x / VoxelCtX, BoxDims.y / VoxelCtY, BoxDims.z / VoxelCtZ);
                VoxelDims_Inv = new Hare.Geometry.Point(1 / VoxelDims.x, 1 / VoxelDims.y, 1 / VoxelDims.z);
                BoxDims_Inv = new Hare.Geometry.Point(1 / BoxDims.x, 1 / BoxDims.y, 1 / BoxDims.z);

                for (int x = 0; x < VoxelCtX; x++)
                {
                    for (int y = 0; y < VoxelCtY; y++)
                    {
                        for (int z = 0; z < VoxelCtZ; z++)
                        {
                            Voxel_Inv[x, y, z] = new List<int>();
                            Hare.Geometry.Point voxelmin = new Hare.Geometry.Point(x * VoxelDims.x, y * VoxelDims.y, z * VoxelDims.z);
                            Hare.Geometry.Point voxelmax = new Hare.Geometry.Point((x + 1) * VoxelDims.x, (y + 1) * VoxelDims.y, (z + 1) * VoxelDims.z);
                            AABB Box = new AABB(voxelmin + OBox.Min_PT, voxelmax + OBox.Min_PT);
                            Voxels[x, y, z] = Box;
                            for (int i = 0; i < Rec_List.Length; i++)
                            {
                                //Check for intersection between voxel x,y,z with Receiver i...
                                Hare.Geometry.Point PT = Box.ClosestPt(Rec_List[i].H_Origin);
                                PT -= Rec_List[i].H_Origin;
                                if ((PT.x * PT.x + PT.y * PT.y + PT.z * PT.z) < Rec_List[i].Radius2)
                                {
                                    Voxel_Inv[x, y, z].Add(i);
                                }
                            }
                        }
                    }
                }
            }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:101,代码来源:Pach_Map_Receiver.cs


注:本文中的AABB.ClosestPt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。