示例#1
0
        public static void GetGeometry(ushort segmentID1, ushort segmentID2,
                                       out FastSegmentList farSegments, out FastSegmentList nearSegments)
        {
            farSegments  = new FastSegmentList();
            nearSegments = new FastSegmentList();
            ushort nodeID = segmentID1.ToSegment().GetSharedNode(segmentID2);
            var    angle0 = GetSegmentsAngle(segmentID1, segmentID2);

            for (int i = 0; i < 8; ++i)
            {
                ushort segmentID = nodeID.ToNode().GetSegment(i);
                if (segmentID == 0 || segmentID == segmentID1 || segmentID == segmentID2)
                {
                    continue;
                }
                var  angle = GetSegmentsAngle(segmentID1, segmentID);
                bool near  = VectorUtil.CompareAngles_CCW_Right(source: angle0, target: angle);
                near = near ^ NetUtil.LHT;
                //Log.Debug($"GetGeometry({segmentID1}, {segmentID2}) : segment:{segmentID}\n" +
                //    $" CompareAngles_CCW_Right(angle0:{angle0*Mathf.Rad2Deg}, angle:{angle*Mathf.Rad2Deg}) -> {near}");
                if (near)
                {
                    nearSegments.Add(segmentID);
                }
                else
                {
                    farSegments.Add(segmentID);
                }
            }
        }
示例#2
0
        public static float GetSegmentsAngle(ushort from, ushort to)
        {
            ushort  nodeID = from.ToSegment().GetSharedNode(to);
            Vector3 dir1   = from.ToSegment().GetDirection(nodeID);
            Vector3 dir2   = to.ToSegment().GetDirection(nodeID);
            float   ret    = VectorUtil.SignedAngleRadCCW(dir1.ToCS2D(), dir2.ToCS2D());

            //Log.Debug($"SignedAngleRadCCW({dir1} , {dir2}) => {ret}\n"+
            //           $"GetSegmentsAngle({from} , {to}) => {ret}");
            return(ret);
        }