I have a robot with red led and green led mounted at the front and back respectively. I want to calculate the head direction of the robot as in which direction is the greenLEd - redLed vector pointed to.
How can I code it such that the points marked 1 and 2 in the image below have the same angle i.e. 45degree anti-clockwise whereas point 3 should be at 225degrees.
I used the following script but it giving me wrong results:
def headDirectionAngle(redLEDCoords, greenLEDCoords, referenceVector):
greenRedLEDVector = np.array(greenLEDCoords) - np.array(redLEDCoords)
angle = np.math.atan2(np.linalg.det([referenceVector,greenRedLEDVector]),np.dot(referenceVector,greenRedLEDVector))
return np.degrees(angle)
referenceVector = np.array([0,240])
How should I proceed? Thanks for the help.