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.
(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
% 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
Problem Comments
4 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers14
Suggested Problems
-
5016 Solvers
-
Find the maximum number of decimal places in a set of numbers
3369 Solvers
-
252 Solvers
-
6085 Solvers
-
76 Solvers
More from this Author33
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The difficult part here wasn't solving the problem as much as understanding it, not otherwise knowing a thing about cricket!
Tip (for people not into cricket): In the image, the blue batter looks at us (it is not a side picture). The wicket is made of three stumps, with names, from left to right: off-stump, middle-stump, and leg-stump. The pad is a protection the batter uses.
Tip #2 (for people not into cricket): LBW means the ball has hit the batter and not the bat first (regardless of whether the hit was on his leg). All the balls in the test suite are candidates for LBW, but the player can purposely take a hit with his body (which can make LBW invalid according to the rules). And that's why there are two rules for when the player is making a genuine move and not.
Thanks, Rafael, for adding the extra info. I didn't want to bloat the instructions with too much detail - to be honest, I didn't expect so many non-cricket-familiar people to try these problems!
Tip #3 (FPNIC): an image search for "lbw review" should bring up plenty of examples of how it looks in reality, with the graphics they overlay on the television coverage. That's roughly what I was channeling when I made the diagrams in the problem statement. (I don't want to include actual images in case I violate any copyright by accident.)