Hi, I need some help with programming the calculation of displacement. Given the distance the object has moved in the XY plane, and the yaw (heading) of the object, I'd like to calculate the displacement of the object. For example, the object moved 5m North and 2m East.
The data I have is the distance it travels in the XY plane (X distance and Y distance) and the heading of the device which is determined by the direction of X. I know how to calculate it on paper but I am having trouble to program it.
I've attached two examples that shows how I obtained the calculations. In the 1st example, the X-distance travelled is 3 meters while the Y-distance is 4 meters and the heading of the X-axis is 70°. After calculating, I managed to get that it has travelled 2.733m South and 4.187m East. In example 2, it travel, the X-distance is -5m and the Y-distance is -12m, the heading is 160°. I calculated that the object travels 8.80m North and 9.566m East.
The angle between the X-axis and the North is determined by the (yaw) heading of the device. It's a value that I measured. However, I'm not sure about the programming to find the angle 33.13° in Example1 and 22.62° in Example2. Is there any quick method to identify the angle as I struggle to identify it myself while calculating.
I assume the 'x' value you mention is the adjacent value between X-distance and Y-distance.