Danmaku_no_Kyojin.Collisions.CollisionCircle.Project C# (CSharp) Method

Project() public method

public Project ( Vector2 axis ) : Vector2
axis Vector2
return Vector2
        public Vector2 Project(Vector2 axis)
        {
            if (!_axes.Contains(axis))
                _axes.Add(axis);

            float a = axis.Y / axis.X;

            float min = Vector2.Dot(new Vector2(GetCenter().X - (float)(Radius * Math.Sin(a)), GetCenter().Y - (float)(Radius * Math.Cos(a))), axis);
            float max = Vector2.Dot(new Vector2(GetCenter().X + (float)(Radius * Math.Sin(a)), GetCenter().Y + (float)(Radius * Math.Cos(a))), axis);

            return new Vector2(min, max);
        }

Usage Example

コード例 #1
0
        private bool Intersects(CollisionCircle element)
        {
            ComputeCircleAxes(element);

            // loop over the axes of this polygon
            for (int i = 0; i < _axes.Count; i++)
            {
                Vector2 axis = _axes[i];
                // project both shapes onto the axis
                Vector2 p1 = this.Project(axis);
                Vector2 p2 = element.Project(axis);

                // do the projections overlap?
                if (!Overlap(p1, p2))
                {
                    // then we can guarantee that the shapes do not overlap
                    return(false);
                }
            }

            // if we get here then we know that every axis had overlap on it
            // so we can guarantee an intersection
            return(true);
        }
All Usage Examples Of Danmaku_no_Kyojin.Collisions.CollisionCircle::Project