1. ## Straight line points

Hi

How to calculate straight line starting point x,y values(a) and ending point x,y values(b). I know the slope of the line , width of the line and center point of the line(c).

2. Originally Posted by kumar
Hi

How to calculate straight line starting point x,y values(a) and ending point x,y values(b). I know the slope of the line , width of the line and center point of the line(c).

If you know the slope, and a point on the line then

I'm guessing here:
Are you looking for the coordinates of a point that is
equidistant left & right from the center point?

$X_a = X_c + HorizontalDistanceLeft$

$Y_a = Y_c + HorizontalDistanceLeft \cdot Slope$

$X_b = X_c + HorizontalDistanceRight$

$Y_b = Y_c + HorizontalDistanceRight \cdot Slope$

You must be aware that
the HorizontalDistanceLeft will be NEGATIVE &
the HorizontalDistanceRight will be POSITIVE.

3. What do you mean by "calculate straight line"? If you know any one point on the line, a, or b, or c, and the slope, m, then the equation of the straight line is $y= m(x- a_x)+ a_y= m(x- b_x)+ b_y= m(x- c_x)+c_y$. You don't need to know the other points or the other information. If you know two points, say a and b, then you can calculate the slope, $m= \frac{a_y- b_y}{a_x- b_x}$.

Do you mean "find the length of the line segment"? If so, any two of the facts you have will suffice.

If you know the end points, a and b, the length is $\sqrt{(a_x- b_x)^2+ (a_y- b_y)^2}$.

If you know and endpoint, either a or b, and the center point, c, then the length is $2\sqrt{a_x- c_x)^2+ (a_y- c_y)^2}$.

If you know the "width of the line" (by which, I take it, you mean the absolute value of the difference in x values of a and b) and the slope then, taking w= "width" and m= "slope", the "height", the absolute value of the difference in y value of a and b, is given by wm and so the length of the line segment is given by $\sqrt{w^2+ (wm)^2}= w\sqrt{1+ m^2}$.