Example #1
0
        public static Vector2f GetEjectingVector(RoundShape first, RoundShape second)
        {
            var direction = (first.Center - second.Center).Normalize();
            var delta     = (first.Radius + second.Radius) - (second.Center - first.Center).Length() + 1;

            return(direction * delta);
        }
Example #2
0
        public static Vector2f GetEjectingVector(RoundShape first, RoundShape second)
        {
            var direction = (first.Center - second.Center).Normalize();
            var delta = (first.Radius + second.Radius) - (second.Center - first.Center).Length() + 1;

            return direction * delta;
        }
Example #3
0
 public PhysicalModel(Vector2f position, Vector2f size, double weight, bool isSolid, bool isStatic)
 {
     Collider       = new AABB(position, size);
     Incircle       = new RoundShape(position + size / 2, Math.Min(Size.X, Size.Y) / 2);
     Circumcircle   = new RoundShape(position + size / 2, size.Length() / 2);
     Position       = position;
     Velocity       = new Vector2f();
     Rotation       = new Vector2f(1, 0);
     IsSolid        = isSolid;
     IsStatic       = isStatic;
     ColliderOffset = new Vector2f();
     Weight         = weight;
 }
Example #4
0
 public PhysicalModel(Vector2f position, Vector2f size, double weight, bool isSolid, bool isStatic)
 {
     Collider = new AABB(position, size);
     Incircle = new RoundShape(position + size / 2, Math.Min(Size.X, Size.Y) / 2);
     Circumcircle = new RoundShape(position + size / 2, size.Length() / 2);
     Position = position;
     Velocity = new Vector2f();
     Rotation = new Vector2f(1, 0);
     IsSolid = isSolid;
     IsStatic = isStatic;
     ColliderOffset = new Vector2f();
     Weight = weight;
 }
        private Vector2f GetDelta(PhysicalModel first, PhysicalModel second)
        {
            switch (mode)
            {
            case PhysicsMode.Incircle:
                return(RoundShape.GetEjectingVector(first.Incircle, second.Incircle));

            case PhysicsMode.Сircumcircle:
                return(RoundShape.GetEjectingVector(first.Circumcircle, second.Circumcircle));

            default:
                return(AABB.GetEjectingVector(first.Collider, second.Collider));
            }
        }
Example #6
0
 public bool Intersects(RoundShape second)
 {
     return((this.Center - second.Center).Length() < this.Radius + second.Radius);
 }
Example #7
0
 public bool Intersects(RoundShape second)
 {
     return (this.Center - second.Center).Length() < this.Radius + second.Radius;
 }