Angle between lines
Quick little demo in response to this forum topic:
It shows how to calculate the angle between two lines, given the start and end co-ordinates of the lines.
Drag the dots to change the angle from the red line to the blue line.
* updated angle to show only 3dp again (Scratch now shows 6dp)
This uses the 2D "vector dot product" (see "Dot_product" on wikipedia) to find the cosine of the angle between the two lines.
It then also does an extra check for the orientation (i.e. whether it's clockwise or anticlockwise) by calculating the (signed) area of the triangle formed by the three points - if the area is positive then the angle is anticlockwise, so it makes the angle negative (which matches the convention used by Scratch for direction angles, and which is the opposite to the convention typically used by mathematicians).