# Math Help - Math formulas for computer screen measurement

1. ## Math formulas for computer screen measurement

Hi
I am trying to create 2 formulas based on computer screen pixel measurements to get the length of a line and its angle of rotation based on knowing the line's start and end position in a 2-dimensional field in space (a computer screen measured in pixels).

My skills are rusty, and I am hoping that someone with geometry/trigonometry skills can suggest these formulas.
The start point is labelled A, and its x and y coordinates are Ax and Ay.
The end point is labelled B, and its x and y coordinates are Bx and By.
If I know Ax, Ay and Bx and By, is it possible to develop formulas that will provide the angle of the line connecting A and B, and provide the length of that line?

Given my limited understanding, it would be most helpful if suggesting formulas to define the elements/components.

Given my limited skills, perhaps there is insufficient information from having only the start and end points as computer screen locations to be able to develop formulas to find the connecting line's angle and length.

Any help would be appreciated.

Kind Regards,
saratogacoach

2. Originally Posted by saratogacoach
Hi
I am trying to create 2 formulas based on computer screen pixel measurements to get the length of a line and its angle of rotation based on knowing the line's start and end position in a 2-dimensional field in space (a computer screen measured in pixels).

My skills are rusty, and I am hoping that someone with geometry/trigonometry skills can suggest these formulas.
The start point is labelled A, and its x and y coordinates are Ax and Ay.
The end point is labelled B, and its x and y coordinates are Bx and By.
If I know Ax, Ay and Bx and By, is it possible to develop formulas that will provide the angle of the line connecting A and B, and provide the length of that line?

Given my limited understanding, it would be most helpful if suggesting formulas to define the elements/components.

Given my limited skills, perhaps there is insufficient information from having only the start and end points as computer screen locations to be able to develop formulas to find the connecting line's angle and length.

Any help would be appreciated.

Kind Regards,
saratogacoach
With respect to the x-axis, the angle is given by:

$Angle = cot \left( \frac{ B_{y} - A_{y} }{ B_{x} - A_{x} } \right)$

EDIT: By subtracting that angle from 90 degrees, you'll get the angle with respect to the y-axis

3. If I know Ax, Ay and Bx and By, is it possible to develop formulas that will provide the angle of the line connecting A and B, and provide the length of that line?

Yes to both.

Angle of the line AB with the horizontal = arctan[(By -Ay) / (Bx -Ax)]

Length of the line AB = sqrt[(By -Ay)^2 +(Bx -Ax)^2]