Sometimes after I see an superior evaluation on the web, I simply need to make it extra awesomer. Really, this must be everybody’s aim on the web—both make stuff or make it extra superior.
In this case, it is a publish from Singletrack (and likewise lined by Boing Boing) taking a look at a selected crossroad in the United Kingdom that results in a big quantity of accidents between bicycles and vehicles. One in 2011, one in 2012, and one other in 2016—all ensuing from the seeming failure of the driver to yield to the bike owner.
In brief, the downside comes about as a result of of the angle of the intersection (it is not perpendicular) and the angle of the blind spot in the automobile from its entrance pillar.
Here’s what I need to do. I need to make an animation in python that reveals the movement of each the automobile and the location of the blind spot (they name it a pillar shadow) on the different street. Once I mannequin the movement of the blind spot, I may also discover its pace. Even higher, after construct a mannequin will probably be tremendous trivial (which is means simpler than trivial) to vary the location of the blind spot or the angle of the intersection.
Before getting began, I want some particulars. According to the Singletack publish, the two roads cross at 69°. Their publish additionally reveals a picture of automobile with its pillar shadow. Using Tracker Video Analysis I can simply measure the angle between the entrance of the automobile and each the main and trailing edge of the shadow (19.four° to 27.1°). Just to be clear, here’s a primary diagram of that shadow. Note that that is in the UK, so the drivers are on the fallacious facet of the automobile.
Also, the unique article assumes that the automobile might be driving at a pace of 37 mph (undecided the place they acquired this however I’ll use the similar worth). Before leaping into python, let me draw an image to assist work out how the calculation will work. Let me begin with simply the forefront of the pillar shadow and its projection onto the different street.
I’ll begin my mannequin in the easiest method—I am simply going to create the forefront of the projection for this pillar shadow. But there’s nonetheless some math to do beforehand. Here’s the way it will go down. If you need extra particulars, I am going to attempt to add sufficient feedback in the code as a way to determine it out.
- The two roads are traces. I can get the equations of these two traces in the type of y = mx + b (slope and intercept). Just for simplicity, each traces will go by way of the origin (level x = zero, y = zero).
- Next, discover the location of the automobile on the first street. I want the x and y coordinate of this automobile (this is not tough).
- Find the equation of the line representing the forefront of the pillar shadow. This is discovered utilizing the point-slope method for a line The slope of the line is discovered from the angle between the entrance of the automobile and the forefront of the shadow.
- Now I want to seek out the intersection between the shadow line equation and the line equation for the second street. The x and y worth for this intersection is the location of the shadow projection.
- Really, that is it. The solely factor left is to maneuver the automobile a little bit bit ahead and repeat the calculation to seek out the subsequent location of the shadow projection.
Yes, it is true. You do not really want a pc program to mannequin the movement of this shadow. If you want you could possibly discover the velocity of the shadow projection with just a few primary math and calculus—I similar to this manner higher.
Now for the first mannequin. Here is the animation of the forefront of the projection. Click the “play” to run the code and the “pencil” to see or edit the code (don’t fret, your edits will not break something).
Right away you need to be capable to discover that the projection of the shadow on the street strikes slower than the precise automobile—however don’t fret, we are going to get to the speeds quickly. Let me make yet one more modification. The following is the similar calculation besides that it reveals each the forefront and the trailing edge of the pillar shadow.
Here you’ll be able to see that as the automobile approaches the intersection, the projection of the pillar shadow onto the street will get smaller. I suppose that must be apparent since the pillar shadow has a single angular width—however nonetheless, it is good to see how that will really look. Also, this may have one vital affect on bicycle speeds. The bike rider does not should journey at the pace of the main or trailing shadow edge—the rider simply wants to remain between these two spots in order to be invisible to the driver (which might be a nasty factor).
I am pretty sure that the main and trailing shadow edges transfer at a continuing pace—however I am not completely sure. Just to make certain, I’m going to make a plot of the place alongside the street for each edges and the automobile (all in their very own dimension). Here is the code (simply in case) and the plot.
From the slopes of these traces, I can discover the shadow edge speeds. I get values of 5.50 m/s and seven.58 m/s (12.three mph and 17.zero mph). That is clearly in the vary of attainable speeds for a human on a bicycle.
But now that you’ve code to calculate the pace of the pillar shadow, you need to use this similar factor for different intersections. What if it is a 90 diploma intersection? What if the automobile is shifting quicker? What in case you have an even bigger angle for the pillar shadow? All of these questions are fairly straightforward to reply by simply altering some numbers in the code. And sure, I already identified that you are able to do this similar calculation on paper—the python stuff is simply enjoyable (and also you get an animation).