Problem 56543. Cricket - Is It LBW?

LBW has an unfair reputation as complicated. But if you've watched a third umpire referral, you'll know that it's just a logical process, based on four decisions: did the ball hit bat or pad first, where did the ball pitch, where was the impact with the pad, would it have hit the stumps? Given three (x,y) coordinate pairs representing the location of where the ball pitched, hit the batter, and would have hit the plane of the wicket, and a logical (T/F) scalar indicating whether the batter was attempting to play the ball, return a logical scalar indicating whether the batter is out LBW (assuming all the other criteria have been met, such as legal delivery, contact with the body before the bat, etc.)
Each coordinate pair is given as a 2-element vector [x y], where the x coordinate is the distance across the pitch, centered on middle stump, with x > 0 corresponding to the batter's off side (and x < 0 corresponding to the batter's leg side).
For the first coordinate pair - ie where the ball pitched - the y coordinate is measured from the bowler's wicket to the batter's wicket (hence 0 < y < 2012). If the ball did not pitch at all, this coordinate vector will be [NaN NaN].
For the other two coordinate pairs, the y coordinate is measured as height above the ground.
For simplicity, you can assume the wicket is a simple rectangle 71.12cm high (ie ) and 22.86cm wide (ie ).
All distances are in cm.
Two diagram showing coordinates. The first shows a cricket pitch with wickets at each end. Coordinate axes are centered on the base of one wicket, the x-axis going across the pitch from right to left, the y-axis going up the pitch to the opposite wicket. A point marked p1 shows the typical location of where the ball might pitch. The second diagram shows a batter in front of a wicket. Coordinate axes are centered on the wicket, again with the x-axis running across the bottom of the wicket from right to left, and the y-axis running vertically up the middle stump. Two points labeled p2 and p3 show the position of typical impacts with the batter's pad (p2) and the plane of the wicket (p3).
(Diagram assumes a right-handed batter)
Law 36 (Leg Before Wicket) states that for the batter to be out LBW:
  • The ball cannot pitch outside the line of leg stump
  • If the batter is making a genuine attempt to play the ball, the impact has to be in line with the wicket (but can be above the height of the wicket)
  • If the batter is not making an attempt to play the ball, the impact has to be in line with the wicket or outside the off stump
  • The ball must have been going on to hit the wicket
Three diagrams showing where the points p1, p2, and p3 must be located for a batter to be out LBW. The first diagram shows p1 in a strip along the pitch from the leg stump across to the off-side edge of the pitch. The second diagram shows p2 impacting the batter's leg. A region covering the width of the wicket extending from the ground upward is marked "if playing the ball". Another region extends this to the off-side of the wicket and is labeled "if not playing the ball". The third diagram shows p3 in a region exactly covering the wicket.
% pitching in line; impact in line (below stump height); playing the ball; hitting wickets => Out
p1 = [4.41 1385.29];
p2 = [-3.03 4.62];
p3 = [-6.3 9.71];
out = islbw(p1,p2,p3,true)
out =
logical
1

Solution Stats

53.57% Correct | 46.43% Incorrect
Last Solution submitted on Nov 03, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers13

Suggested Problems

More from this Author22

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!