コード例 #1
0
        public ProjectionToSurface ProjectToSurface(ASurface surface)
        {
            var surfaceNormal = surface.Normal;

            return(new ProjectionToSurface()
            {
                Position = (Position - surface.Position).ProjectToNormalVector(surfaceNormal),
                Speed = (Speed - surface.Speed).ProjectToNormalVector(surfaceNormal)
            });
        }
コード例 #2
0
        public void ProcessHit(ASurface surface, double horizontalHitCoeff, double verticalHitCoeff, int side = 1, Ball[] derivatives = null)
        {
            var surfaceNormal = surface.Normal * side;
            var projection    = ProjectToSurface(surface);

            projection.Position.Vertical = 2 * Constants.BallRadius * surfaceNormal - projection.Position.Vertical;
            projection.Speed.Vertical   *= -verticalHitCoeff;
            var ballPoint = -Constants.BallRadius * surfaceNormal;
            var fullPerpendicularSpeed = projection.Speed.Horizontal + Point3D.VectorMult(ballPoint, AngularSpeed);
            var force = -horizontalHitCoeff * fullPerpendicularSpeed;

            projection.Speed.Horizontal += force;
            AngularSpeed += Point3D.VectorMult(force, ballPoint.Normal) / Constants.BallRadius;
            RestoreFromSurfaceProjection(surface, projection);
        }
コード例 #3
0
 public void RestoreFromSurfaceProjection(ASurface surface, ProjectionToSurface projection)
 {
     Position = surface.Position + projection.Position.Full;
     Speed    = surface.Speed + projection.Speed.Full;
 }