I need to draw parallel lines between two squares. They can be placed at angle. I need to find out 6 points (3 on square A and 3 on square B) so that lines drawn between them are equally spaced. Thanks
I need to draw parallel lines between two squares. They can be placed at
Share
Best you get acquainted with a bit of vector math.
Ideally the lines would orient themselves to the vector between the centers of the two squares (x0, y0) – (x1, y1).
The direction of the three lines is:
A vector 90° to (x, y), and with size 1:
So a line 10 px from the center would be
Use -10.vn, 0, +10.vn for the three lines.
Determine intersection points with square’s edges (µ > 0 for first square).
As it is rewarding for ones self-consciousness, I leave the solution to you. It also is not as readable anymore.