rotating lines in 2d space


I’m struggeling with with a problem and culd use some help.

I have 2 lines somewhere in 2D space. One line is described by two known points p1, p2.
The other line is described by the unknown points p3, p4, but with a known length.
Now I need to connect p3 of the second line to either p1 or p2. The direction/alignment of the second line is defined by a known angle between the first line.
My problem now is to determine the second point p4 of the second line, given by p1, p2, p3 connected with either p1 or p2 and the angle between those lines.
I guess I have to apply some sort of rotation but I can’t figure out how.

Any ideas?

Thanks in advance for any help!

By lines, do you actually mean line segments here? If yes:

You know P1 and P2. You don’t know P3 and P4 but you know distance(P3,P4). Also you know the angle between the two line segments. Puttin all this together, you end up with any two point on a line, whose distance is the dist(P3,P4) and this line is at a certain angle with line(P1,P2).

The description above gives you an infinite number of possible line(P3,P4) and for each one of these line, an infinite number of P3,P4 pairs.

If you connect P3 with , say, P1, that places the line(P3,P4) on a cone, the apex of which is P1(and P3), and the acis is the line(P1,P2). In order to actually place P4, you need a second angle, around the line(P1,P2) axis.


p1, p2, p3, and p4 have x and y components, defined by p#x and p#y.

r is the length from p3 to p4

t is the angle between the two lines
p3 = //p1 or p2, however you want to define that
dx = p2x-p1x;
dy = p2y-p1y;
dx = p1x-p2x;
dy = p1y-p2y;
nx = p1x/sqrt(dxdx + dydy);
ny = p1y/sqrt(dxdx + dydy);

p4x = p3x + nx *(r * cos(t));
p4y = p3x + nx *(r * sin(t));