Coordinates of a point after rotating a line from one end

321 Views Asked by At

I am working on a project in javascript and p5.js and am stuck at this point. I have to rotate a line from one of its ends with a certain angle in Radians/Degrees. Here's what I want to get-the image

Sorry for my bad drawing. So I want a formula to get C(x,y) to use in my code.

What should be the values of x and y in terms of t-ratios and x1,y1,x2,y2

Sorry,flip the positions of A and B.

3

There are 3 best solutions below

0
On

A \theta counterclockwise rotation matrix about the origin takes an (x,y) input and gives an output $(x cos \theta - y sin \theta, x sin \theta + y cos \theta) $. So you can shift your angle vertex to the origin, perform the rotation, and then shift back; if A is the vertex with coordinates (x1,y1) then subtract that from B, transform, and then add A back on to get C(x,y).

3
On

Starting with your corrected sketch:

enter image description here

HINT: Let point $D$ be a point on $\overline{AB}$ such that angle $\angle{ADC}$ is a right angle. Using trig functions, we can then calculate the side lengths of $\triangle ADC$. Do you see how those side lengths would be enough to find $(x,y)$?

enter image description here

1
On

Using complex numbers, translate both points to bring the rotation center to the origin, rotate by multiplying by $e^{i\theta}$ and translate back to the original center.

$$q'=(q-p)e^{i\theta}+p.$$

You can rewrite this formula using real numbers only.