コード例 #1
0
 public override bool Interact(ref SimulationPoint p)
 {
     if (base.Interact(ref p))
     {
         p = p.Replace(p.Location, p.Previous + _acc);
         return(true);
     }
     return(false);
 }
コード例 #2
0
 public virtual bool Interact(ref SimulationPoint p)
 {
     if (Vector2d.Dot(p.Momentum, DiffNormal) > 0)
     {
         var startDelta = p.Location - this.Position;
         var disty      = Vector2d.Dot(DiffNormal, startDelta);
         if (disty > 0 && disty < Zone)
         {
             var distx = Vector2d.Dot(startDelta, Difference) * DotScalar;
             if (distx <= limit_right && distx >= limit_left)
             {
                 var pos  = p.Location - disty * DiffNormal;
                 var prev = p.Previous;
                 if (p.Friction != 0)
                 {
                     var friction = DiffNormal.Yx * p.Friction * disty;
                     if (p.Previous.X >= pos.X)
                     {
                         friction.X = -friction.X;
                     }
                     if (p.Previous.Y >= pos.Y)
                     {
                         friction.Y = -friction.Y;
                     }
                     p = p.Replace(pos, p.Previous + friction);
                 }
                 else
                 {
                     p = p.Replace(pos);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }