point of an equilateral triangle I'm trying to draw with Java programming language a Koch fractal to emulate a winter snowflake (it is winter, yeah! : )
If I have 2 points P1(0,0) and P2(10, 0), find P3 of the equilateral triangle P1-P2-P3. It's quite easy, I take the midpoint of P1-P2, and add the height of an equilateral triangle ($h=\frac{l}{2}\sqrt{3}$).
So: 
$$P3.x = (P2.x-P1.x)/2$$
$$P3.y = (P2.y-P1.y)/2 + \frac{P2.y-P1.y}{2}\sqrt{3}$$
But what if I have 2 arbitrary points? How can I get the third?
For example if I have P1(10, 25) and P2(42, 79) ?
Sorry if I haven't used the best notation and if don't know how to draw a nice figure to better explanation in latex!
 A: The matrices for rotation by $\pi/3$ and $-\pi/3$ are
$$
M_+=\begin{bmatrix}1/2&\sqrt{3}/2\\-\sqrt{3}/2&1/2\end{bmatrix}
$$
and 
$$
M_-=\begin{bmatrix}1/2&-\sqrt{3}/2\\\sqrt{3}/2&1/2\end{bmatrix}
$$

yielding the vertices for the two equilateral triangles:
$$
\begin{align}
&\begin{bmatrix}x_1&y_1\end{bmatrix}+\begin{bmatrix}x_2-x_1&y_2-y_1\end{bmatrix}\begin{bmatrix}1/2&\sqrt{3}/2\\-\sqrt{3}/2&1/2\end{bmatrix}\\&=\frac{1}{2}\begin{bmatrix}(x_2+x_1)-\sqrt{3}(y_2-y_1)&(y_2+y_1)+\sqrt{3}(x_2-x_1)\end{bmatrix}
\end{align}
$$
and
$$
\begin{align}
&\begin{bmatrix}x_1&y_1\end{bmatrix}+\begin{bmatrix}x_2-x_1&y_2-y_1\end{bmatrix}\begin{bmatrix}1/2&-\sqrt{3}/2\\\sqrt{3}/2&1/2\end{bmatrix}\\&=\frac{1}{2}\begin{bmatrix}(x_2+x_1)+\sqrt{3}(y_2-y_1)&(y_2+y_1)-\sqrt{3}(x_2-x_1)\end{bmatrix}
\end{align}
$$
A: Since I feel that trigonometry is sooo underused in applications like this, here's an alternate method. But first, a diagram:

Let's start with a line at an angle $\theta$ from the horizontal axis. From this, we want to find the slope of the line at an angle $\theta+\varphi$ from horizontal. This is easily obtained through the addition formula for the tangent:
$$\tan(\theta +\varphi )=\frac{\tan\,\theta+\tan\,\varphi}{1-\tan\,\theta \tan \,\varphi}$$
Now, let's use our example again. We know that $\tan\,\theta=\dfrac{27}{16}$. The point we need can be found by changing $\varphi$ accordingly; I'll show how to determine one of the possible points, and leave the other one as an exercise.
We can take the line passing through $(10,25)$ to have the slope $\tan(\theta-2\pi/3)$, and the line passing through $(42,79)$ to have the slope $\tan(\theta+2\pi/3)$. This results in the pair of lines
$$\begin{align*}y-25&=\frac{\frac{27}{16}-\tan\frac{2\pi}{3}}{1+\frac{27}{16}\tan\frac{2\pi}{3}}(x-10)\\y-79&=\frac{\frac{27}{16}+\tan\frac{2\pi}{3}}{1-\frac{27}{16}\tan\frac{2\pi}{3}}(x-42)\end{align*}$$
Finding the intersection of these two lines through the usual means yields the point $(26-27\sqrt3,52+16\sqrt3)$.
A: Say you have two points that are the ends of one side of the triangle, $P1=(P1.x,P1.y)$ and $P2=(P2.x,P2.y)$.  The length of the side is $s=\sqrt{(P2.x-P1.x)^2+(P2.y-P1.y)^2}$ The midpoint of the side is $MP=(\frac{P1.x+P2.x}2,\frac{P1.y+P2.y}2)$.  The slope of the segment from $P1$ to $P2$ is $m=\frac{P2.y-P1.y}{P2.x-P1.x}$, and the slope of the perpendicular (which will pass through the other vertex) is $-\frac1m$, which makes a unit vector $U=(\frac{\pm m}{1+m^2},\frac{\mp 1}{1+m^2})$.  So you can use the point-slope form to find the third point.  $P3=MP+Us$.  There will be two solutions, one each side of the segment.
A: I'll use your example of $(x_1,y_1)=(10,25)$ and $(x_2,y_2)=(42,79)$ to illustrate the idea. This is merely a reformulation of the answers given so far, but this might be a bit more convenient.
To get a few things we need out of the way, we compute the midpoint $(x_c,y_c)=(26,52)$, the segment length $d=2\sqrt{985}$, and the slope $m=\dfrac{27}{16}$.
The line perpendicular to our given segment has the slope $-\dfrac1{m}=-\dfrac{16}{27}$ and passes through $(x_c,y_c)$. A particularly convenient parametrization of this line is
$$\begin{align*}x&=x_c+\frac{mu}{\sqrt{1+m^2}}\\y&=y_c-\frac{u}{\sqrt{1+m^2}}\end{align*}$$
(See the stuff below the dividing line for a derivation.)
To get any of the two needed points we replace $u$ in the line parametrization with $u=\pm d\dfrac{\sqrt 3}{2}=\pm\sqrt{2955}$; this yields the points $(26\pm27\sqrt 3,52\mp16\sqrt 3)$.

Deriving a convenient parametrization for the line
Start with the usual point-slope form of the line:
$$y-y_1=m(x-x_1)$$
It is known that if the line makes an angle $\theta$ with respect to the horizontal axis, then $m=\tan\,\theta$. We can thus also consider the alternative form
$$\frac{y-y_1}{\sin\,\theta}=\frac{x-x_1}{\cos\,\theta}$$
Equate the two sides of this equation to a new parameter $u$, yielding
$$\begin{align*}x&=x_1+u\cos\,\theta\\y&=y_1+u\sin\,\theta\end{align*}$$
To remove $\theta$, we use the relation $\theta=\arctan\,u$, and express the cosine and sine entirely in terms of the tangent:
$$\begin{align*}\cos\,\theta&=\frac1{\sqrt{1+\tan^2 \theta}}\\\sin\,\theta&=\frac{\tan\,\theta}{\sqrt{1+\tan^2 \theta}}\end{align*}$$
This finally yields
$$\begin{align*}x&=x_1+\frac{u}{\sqrt{1+m^2}}\\y&=y_1+\frac{um}{\sqrt{1+m^2}}\end{align*}$$
The "convenient" part is due to the fact that $u$ can be interpreted as (signed) distance; that is, if $u=\pm h$, then the length of the segment joining the resulting point and $(x_1,y_1)$ is $h$. The sign determines any of the two directions one can proceed from the starting point.
A similar formula for the perpendicular is conveniently realized by replacing $m$ with $-\dfrac1{m}$.
A: you can find the intersection of 2 circles:
both have a radius of $|P_1P_2|$ and the first circle has midpoint $P_1$ and the second circle has midpoint $P_2$
$$\begin{cases}(x-x_1)^2+(y-y_1)^2=|P_1P_2|^2 \\
(x-x_2)^2+(y-y_2)^2=|P_1P_2|^2 \end{cases}$$
$$\begin{cases}(x-x_1)^2+(y-y_1)^2=(x_2-x_1)^2+(y_2-y_1)^2 \\
(x-x_2)^2+(y-y_2)^2=(x_2-x_1)^2+(y_2-y_1)^2 \end{cases}$$
