M HYPE SPLASH
// general

calculate the new end points of line after rotating an angle

By Emily Wilson
$\begingroup$

i have two lines, one is slanted line and another is a straight line. Both the lines share same X coordinate separated by distance d. The straight line is rotated to an angle θ (which also needed to be calculated from slanted line) ,making it parallel to the slanted line. Now how to calculate the new end points X2,Y2 of the rotated line?

  • I used the slope equation to find the m1 of the slanted line and then converted it into angle using m=tanθ formula.
  • Now how to calculate the new X2,Y2 after rotating the line?

enter image description here

$\endgroup$ 1

2 Answers

$\begingroup$

No need to compute any angles or trigonometric functions of them directly. Since you want to end up parallel to the second line segment after rotation, you already have a vector that’s pointing in the right direction, namely $P_4-P_3$. You just need to adjust its length and add it to $P_0$: $$P_2=P_0+{\lvert P_1-P_0\rvert\over\lvert P_4-P_3\rvert}(P_4-P_3).$$

$\endgroup$ 4 $\begingroup$

Let $AB$ the segment from $(x_0,y_0)$ to $(x_1,y_1)$. Note that when you rotate the segment $AB$ this point that we call $P$ rotates, describing an arc of angle $\theta$.

So, let the origin $O(x_0,y_0)$, and draw the perpendicular line to the segment $AB$ from $S(x_2,y_2)$. Let $K$ the intersection, the triangle $SOK$ is a right triangle. So:$$x_2=|x_1|\cos(\theta)$$and:$$y_2=|x_1|\sin(\theta)$$Note that we can write $|x_1|$ bevause we assume that the segment $AB$ is part of $x-$axis.

$\endgroup$ 3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy