# Generalized formula for third point to form an equilateral triangle

We know two complex numbers $$z_A,z_B$$ corresponding to points $$A$$ and $$B$$ in the complex plane. We need to generally find $$z_C$$ corresponding to point $$C$$ such that $$\triangle ABC$$ is equilateral.

Note: $$\exists~2$$ points $$C_1$$ and $$C_2$$ that satisfy the condition.

We know that in an equilateral triangle $$h=\frac{\sqrt{3}}{2}l$$. We have to go from the middle point $$M~~\frac{\sqrt{3}}{2}|\vec{AB}|$$ either up or down.

Let $$O\in\mathcal{P}$$.

$$\vec{OC}=\vec{OM}+\vec{MC}$$

$$\vec{OM}=\frac{1}{2}(\vec{OA}+\vec{OB})$$

We are left to find $$\vec{MC}$$.

$$\vec{i}$$ and $$\vec{j}$$ are the unit vectors of $$O_x$$ and $$O_y$$ respectively

$$\vec{BA}\cdot\vec{i}=|\vec{AB}|\cdot|\vec{i}|\cdot cos\alpha$$

$$((x_A-x_B)\vec{i}+(y_A-y_B)\vec{j})\cdot\vec{i}=|\vec{AB}|\cdot cos\alpha$$

$$x_A-x_B=|\vec{AB}|\cdot cos\alpha\Rightarrow cos\alpha=\frac{x_A-x_B}{|\vec{AB}|}$$

$$|\vec{BA}\times\vec{i}|=|\vec{AB}|\cdot|\vec{i}|\cdot sin\alpha$$

$$|((x_A-x_B)\vec{i}+(y_A-y_B)\vec{j})\times\vec{i}|=|\vec{AB}|\cdot sin\alpha$$

$$|y_A-y_B|=|\vec{AB}|\cdot sin\alpha\Rightarrow sin\alpha=\frac{|y_A-y_B|}{|\vec{AB}|}$$

$$sin(\frac{\pi}{2}-\alpha)=cos\alpha\Rightarrow sin\theta=cos\alpha$$

$$cos(\frac{\pi}{2}-\alpha)=sin\alpha\Rightarrow cos\theta=sin\alpha$$

$$\vec{MC}=\pm|\vec{MC}|(cos\theta\cdot\vec{i}+sin\theta\cdot\vec{j})$$ (we have $$\pm$$ because we can go either up or down)

$$|\vec{MC}|=\frac{\sqrt{3}}{2}|\vec{AB}|$$

$$\vec{MC}=\pm\frac{\sqrt{3}}{2}|\vec{AB}|(\frac{|y_A-y_B|}{|\vec{AB}|}\vec{i}+\frac{x_A-x_B}{|\vec{AB}|}\vec{j})$$

$$\vec{MC}=\pm\frac{\sqrt{3}}{2}(|y_A-y_B|\vec{i}+(x_A-x_B)\vec{j})$$

$$\vec{OC}=\frac{1}{2}(\vec{OA}+\vec{OB})\pm\frac{\sqrt{3}}{2}(|y_A-y_B|\vec{i}+(x_A-x_B)\vec{j})$$

Transforming into a complex equation we get:

$$z_C=\frac{1}{2}(z_A+z_B)\pm\frac{\sqrt{3}}{2}(|Im(z_A)-Im(z_B)|+(Re(z_A)-Re(z_B))i)$$

However, this does not seem to work when I graphically represent the points (I use Desmos). What do I do wrong?

EDIT:

I've figured out what I did wrong. I did not consider $$\alpha$$ in the trigonometrical sense. The marked answer inspired me to solve the problem using the Euler formula.

To find $$\alpha$$ we have to imagine a translation such that $$A$$ is in the center of the orthogonal axis. We will consider $$\alpha=\angle(\vec{AB};\vec{i})$$ in the trigonometrical sense with $$\alpha\in[-\pi;\pi]$$. Hence,

$$cos\alpha=\frac{Re(z_2)-Re(z_1)}{|z_2-z_1|}$$

$$sin\alpha=\frac{Im(z_2)-Im(z_1)}{|z_2-z_1|}$$

We need to rotate $$B$$ from $$\vec{AB}$$ to the left (counter-clockwise) or to the right (clockwise) $$\pm\frac{\pi}{3}$$. Let's first consider the $$+$$ case.

$$\delta=\alpha+\frac{\pi}{3}$$

$$cos\delta=cos(\alpha+\frac{\pi}{3})=\frac{1}{2}\cdot\frac{Re(z_2)-Re(z_1)}{|z_2-z_1|}-\frac{\sqrt{3}}{2}\cdot\frac{Im(z_2)-Im(z_1)}{|z_2-z_1|}$$

$$sin\delta=sin(\alpha+\frac{\pi}{3})=\frac{1}{2}\cdot\frac{Im(z_2)-Im(z_1)}{|z_2-z_1|}+\frac{\sqrt{3}}{2}\cdot\frac{Re(z_2)-Re(z_1)}{|z_2-z_1|}$$

Let $$\vec{r}$$ be the unit vector oriented to the angle after the rotation.

$$r=e^{i\delta}=cos\delta+i\cdot sin\delta=\frac{1}{2|z_2-z_1|}\Big(\big(\underbrace{Re(z_2)+i\cdot Im(z_2)}_{z_2}\big)-\big(\underbrace{Re(z_1)+i\cdot Im(z_1)}_{z_1}\big)+\sqrt{3}\big(\underbrace{i\cdot Re(z_2)-Im(z_2)}_{iz_2}\big)-\sqrt{3}\big(\underbrace{i\cdot Re(z_1)-Im(z_1)}_{iz_1}\big)\Big)$$

$$r=\frac{1}{2}\cdot\frac{z_2-z_1}{|z_2-z_1|}\cdot(1+i\sqrt{3})$$

$$z_3=z_1+|z_2-z_1|r$$

$$z_3=z_1+\frac{1}{2}(z_2-z_1)(1+i\sqrt{3})$$

As for the $$-$$ case we are similarly going to get

$$z_3=z_1+\frac{1}{2}(z_2-z_1)(1-i\sqrt{3})$$

$$\mathbf{z_3=z_1+(\frac{1}{2}\pm\frac{\sqrt{3}}{2}i)(z_2-z_1)}$$

And what's most interesting to it is that $$\frac{1}{2}\pm\frac{\sqrt{3}}{2}i$$ turns out to be $$-\omega$$, where $$\omega=\sqrt[3]{1}~$$, the primitive cube root of unity.

So we can clearly say that

$$\mathbf{z_3=z_1+\omega(z_1-z_2),~\omega\in\mathbb{C}-\mathbb{R}}$$

EDIT2: I've just finished the project.

Here is the source code:

https://github.com/s1mplex-Neox/Koch/blob/main/koch.cpp

Here is the video:

https://youtu.be/cyuEGvcgLY8

I think you are overthinking this problem. Try this approach: let $$\alpha=\angle(z2-z1)$$. The the third point to create an equilateral triangle is given by

$$z_3=z_2+|z_2-z_1|e^{i(\pi+\alpha-\pi/3)}$$

• Your answer gave me a strong suggestion to discover the generalized formula. I don't know how I couldn't come up with the Euler formula. I'll edit the post to show what I've done.
– Neox
Commented Jun 30, 2021 at 12:11
• @Neox I find that you are still making this too complicated. Moreover, I find the final answer does not give correct results numerically/graphically for random $z_{1,2}$ on the plane, Commented Jun 30, 2021 at 15:14
• Can you please give me an example that gives incorrect results according to my final formula?
– Neox
Commented Jun 30, 2021 at 15:19
• I've just created a C++ program that calculates $z_3$ according to my formula and calculates the distances between $A$, $B$ and $C$. They are always equal. Do you want me to show you the code?
– Neox
Commented Jun 30, 2021 at 15:37
• Also, you said that I am overcomplicating it. I just want to remind you that I need an exact answer, not something with $e^{i...}$, since I'm working on a project to simulate a fractal and I must plug in numerical coordinates.
– Neox
Commented Jun 30, 2021 at 16:04

Direct approach: $$|z_c-z_b|=|z_c-z_a|=|z_a-z_b|$$ Leading to:

$$x_c^2+y_c^2-2(x_ax_c+y_ay_c)=x_b^2+y_b^2-2(x_ax_b+y_ay_b)$$ $$x_c^2+y_c^2-2(x_bx_c+y_by_c)=x_a^2+y_a^2-2(x_ax_b+y_ay_b)$$

Solve for $$x_c$$ and $$y_c$$. Solution approach. Combine equation to eliminate $$x_c^1+y_c^2$$ to get linear relation between $$x_c$$ and $$y_c$$. Plug into one of original pair to get quadratic. There are obviously two possible solutions

• Hi. At first glance I tried your approach and I also got a system of a linear and a quadratic equation, but it was pretty hard to solve it and get a generalized formula. I would be very thankful if you could tell me where my mistake is.
– Neox
Commented Jun 28, 2021 at 19:10
• I have difficulty plowing through what you did. However using your basic idea I would suggest the following. Get the straight line through $z_a$ and $z_b$ It will look like $y=mx+b$, where $m=\frac{y_b-y_a}{x_b-x_a}$ and $b=y_m-mx_m$ with $z_m=\frac{z_a+z_b}{2}$ Then the two solutions you want are along a line $y=\frac{-x}{m}+c$ where $c=y_m+\frac{x_m}{m}$. Commented Jun 28, 2021 at 21:50