コード例 #1
0
        public Rect GetAABB()
        {
            var ll   = LowerLeft;
            var lr   = LowerRight;
            var ul   = UpperLeft;
            var ur   = UpperRight;
            var minx = TWMath.Min(ll.x, lr.x, ul.x, ur.x);
            var miny = TWMath.Min(ll.y, lr.y, ul.y, ur.y);
            var maxx = TWMath.Max(ll.x, lr.x, ul.x, ur.x);
            var maxy = TWMath.Max(ll.y, lr.y, ul.y, ur.y);

            return(new Rect(minx, miny, maxx - minx, maxy - miny));
        }
コード例 #2
0
        private static bool SeparatesOnAxis(Vector2 axis, float aMin, float aMax, Vector2 b1, Vector2 b2, Vector2 b3, Vector2 b4)
        {
            var dotb1 = Vector2.Dot(axis, b1);
            var dotb2 = Vector2.Dot(axis, b2);
            var dotb3 = Vector2.Dot(axis, b3);
            var dotb4 = Vector2.Dot(axis, b4);

            var bMin = TWMath.Min(dotb1, dotb2, dotb3, dotb4);
            var bMax = TWMath.Max(dotb1, dotb2, dotb3, dotb4);


            if (aMin > bMax || bMin > aMax)
            {
                return(true);
            }
            return(false);
        }