# How to find points of a reflected 2d bezier curve about a line

Pardon me if this sounds primitive. I have created a bezier curve with control points A, B, C, D, which are known (see image below). How can I find control points B1, C1, D1 for a new bezier curve reflected in AR1 and A2, B2 and C2 for a new bezier curve reflected in DR2?

• Can AR1 be an arbitary line segment or only paralell to the y axis? Sep 24, 2018 at 5:49
• @Bálint AR1 should be arbitrary, but as a reflection line the distance from D1 to R1 should be the same as R1 to D and so on. Sep 24, 2018 at 6:57
• Still trying to get this solved Sep 25, 2018 at 15:43

Take the line going through AR1, the equation of this lines is

(x-A.x)(R1.y-A.y)=(y-A.y)(R1.x-A.x)
(R1.y-A.y)x - (R1.x-A.x)y = A.x(R1.y-A.y)-A.y(R1.x-A.x)


So the normal vector of this line is (R1.y-A.y, R1.x-A.x). This is the direction vector of the line perpendicular to it and since that goes through D, we can get the equation of that as well:

(R1.x-A.x)x-(R1.y-A.y)y=(R1.x-A.x)D.x-(R1.y-A.y)D.y


From this we isolate x for later use:

x = ((R1.x-A.x)D.x-((R1.y-A.y)(D.y+y))/(R1.x-A.x)
x = D.x - (R1.y-A.y)(D.y+y)/(R1.x-A.x)


Then we replace x in the other line's equation using this

(D.y+y)(R1.y-A.y)^2/(R1.x-A.x) - (R1.x-A.x)y = A.x(R1.y-A.y)-A.y(R1.x-A.x)


We then isolate y

y = (A.x(R1.y-A.y)-A.y(R1.x-A.x)-D.y*(R1.y-A.y)^2/(R1.x-A.x))/(R1.x-A.x+(R1.y-A.y)^2/(R1.x-A.x))


This is the only equation you actually need to implement.The right side should be given. After you find y, use it to calculate x using the

x = D.x - (R1.y-A.y)(D.y+y)/(R1.x-A.x)


equation

You should now have the coordinates of the closest point on the AR1 line to the D point (I suggest abstracting it and implementing a function, that given a line and a point does this, since you need to use it a couple of times). Now you just get the vector pointing from D to this new point, multiply it by 2 and add it to D to get D'. Repeat this process with C and B and you should have every control point.

• I am trying to understand your answer. I don't know R1 and everything seems to be in terms of R1. I would be grateful if you would explicitly show how to calculate the points (or some of them) using C#, since I I used the Unity tag for the question. Sep 24, 2018 at 10:33
• @coderificated Those are points, in unity You'd use vectors. If you do that, then you can almost just copy and paste it and they should work apart from the ^2 (which should be changed to a squareing) and how I didn't use * between some expressions Sep 24, 2018 at 10:40
• To be honest with you, I'm really not sure how to arrive at D1 or the other points from your answer. You have provided the coordinates of the equation of a line AR1 but none of the points I asked in the question. Sep 24, 2018 at 11:36
• @coderificated there's no D1, only D, and you should already have that since you used it to define the bezier curve Sep 24, 2018 at 12:13
• From the question I posted I don't know B1, C1, D1, A2, B2 and C2 Sep 24, 2018 at 12:27