I am stuck at a problem. I am trying to solve it for 2 days. But I am clueless. It can be something simple but just i am clueless at the moment & any help is appreciated.
I want to make a line from A(x1, y1) to B(x2, y2) of fixed length.
A.............B
A....B........
A............. B
I have made a mobile cricket scorer. In reports it builds a wagon wheel. As it is used from mobile the human touch is not very accurate and people do not always touch the boundary line (dark orange circle in image below).
But when I am generating a report in PHP, I must draw a line from fixed starting point to the boundary line in the direction where they touched.
Right now my WAGON WHEEL looks like this.
I have tried many ways to accomplish this but all failed. Now my next idea is to draw a line of fixed length from fixed starting point (batting side) to the touch co-ordinates but of fixed length so that the line always end at boundary line no matter if the users' touch is not accurate.
I can calculate the distance between starting point and touch point using this in php
$lineLength = round( sqrt (pow(($wicketX-$x),2) + pow(($wicketY-$y),2)), 2);
But I dont know how to further adjust by touch co-ordinates to required length
Please please please help.
P.S. This question looked something similar but i figure out. My maths is week Calculate a point along the line A-B at a given distance from A