示例#1
0
        private bool IsVisiblePoint(Vector3 center, Vector3 pos, out NormalizedPoint point)
        {
            var delta  = pos - center;
            var sqrMag = delta.sqrMagnitude;

            if (sqrMag >= m_MinDistanceSqr && sqrMag <= m_MaxDistanceSqr)
            {
                var lonLat = Geometry.GetLonLat(m_ReferenceFrame, delta);
                if (m_LonLatRect.Contains(lonLat))
                {
                    float d = Mathf.Sqrt(sqrMag) - m_MinDistance; // > 0
                    // lon/lat -> norm. x/y
                    point.Position   = Rect.PointToNormalized(m_LonLatRect, lonLat);
                    point.Position.z = d / m_DistanceRange;
                    point.Position.z = m_ApplyWeight
                        ? Normalization.InvSigmoid(point.Position.z, m_NormalizationWeight)
                        : 1 - point.Position.z;                // 0 at max, 1 at min distance
                    point.DistanceRatio = m_DistanceRange / d; // 1 at max distance

                    return(true);
                }
            }

            point = default;
            return(false);
        }
示例#2
0
        private bool EncodePoint(NormalizedPoint point, int distanceChannel, int onehotChannel, out Vector2Int gridPos)
        {
            gridPos = m_Grid.NormalizedToGridPos(point.Position);

            // Shorter distances have higher normalized values.
            bool write = point.Position.z > m_Grid.Read(distanceChannel, gridPos);

            if (write)
            {
                m_Grid.Write(distanceChannel, gridPos, point.Position.z);
            }

            if (onehotChannel != -1)
            {
                m_Grid.Write(onehotChannel, gridPos, 1);
            }

            return(write);
        }
示例#3
0
 public void AddPoint(NormalizedPoint point)
 {
     m_Points.Add(point);
     m_Rect.min = Vector2.Min(m_Rect.min, point.Position);
     m_Rect.max = Vector2.Max(m_Rect.max, point.Position);
 }