Beispiel #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);
        }
Beispiel #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;
        }
 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;
 }
 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));
            }
        }
Beispiel #6
0
 public bool Intersects(RoundShape second)
 {
     return((this.Center - second.Center).Length() < this.Radius + second.Radius);
 }
Beispiel #7
0
 public bool Intersects(RoundShape second)
 {
     return (this.Center - second.Center).Length() < this.Radius + second.Radius;
 }