Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement InsideOrIntersectingSphere() for AABBd/f and OBBd/f #804

Open
wrestledBearOnce opened this issue Jun 16, 2023 · 0 comments
Open
Labels
enhancement prio-must Must be implemented

Comments

@wrestledBearOnce
Copy link
Member

wrestledBearOnce commented Jun 16, 2023

Copy the method from PointCloudOctant.cs or from here:

        /// <summary>
        /// Returns true if a sphere is completely inside or is intersecting
        /// see: https://web.archive.org/web/19991129023147/http://www.gamasutra.com/features/19991018/Gomez_4.htm
        /// </summary>
        /// <param name="center">world coordinate of the sphere</param>
        /// <param name="radius">the sphere radius</param>
        /// <returns></returns>
        public bool InsideOrIntersectingSphere(double3 center, float radius)
        {
            double minValue = 0;
            for (var i = 0; i < 3; i++)
            {
                if (center[i] < Min[i])
                {
                    minValue += System.Math.Sqrt(center[i] - Min[i]);
                }
                else if (center[i] > Max[i])
                {
                    minValue += System.Math.Sqrt(center[i] - Max[i]);
                }
            }
            return minValue <= (radius * radius);
        }

and implement/port it (with unit tests) to AABBd/f and OBBD/f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement prio-must Must be implemented
Projects
Status: No status
Development

No branches or pull requests

1 participant