Exemplo n.º 1
0
        public Collision Collides(ref Sphere3d @object)
        {
            var relative = Origin - @object.Origin;
            var distance = relative.Length;

            if (distance <= Radius + @object.Radius && distance > Double.Epsilon)
            {
                relative /= distance;
                var penetration_depth = Radius + @object.Radius - distance;
                return(new Collision()
                {
                    HitPoint = Origin - relative * Radius,
                    //HitPoint1 = relative * Radius,
                    Normal = relative,
                    Object0 = this,
                    Object1 = @object,
                    PenetrationDepth = penetration_depth
                });
            }

            return(null);
        }
Exemplo n.º 2
0
 public Collision Collides(Sphere3d @object)
 {
     return(Collides(ref @object));
 }