If I have a series of three vertices that make up a triangle, how can I take one of these vertices and find the edges that go from that vertex to the other two vertices?
$\endgroup$ 11 Answer
$\begingroup$Given three vertices $(x_{1}, y_{1}), (x_{2}, y_{2}), (x_{3}, y_{3})$, you can find the edge between them using the slope-formula:
$m = \frac{y_{2} - y_{1}}{x_{2} - x_{1}}$
Then solve for $b$: $y_{1} = mx_{1} + b$.
From there, you have a line to plot from $(x_{1}, y_{1})$ to $(x_{2}, y_{2})$.
Consider the example: $(1, 1), (2, 3)$.
So $m = \frac{3-1}{2-1} = 2$.
And we solve: $1 = 2(1) + b \implies b = -1$.
So the edge connecting $(1, 1), (2, 3)$ is given by the line: $y = 2x - 1$. Of course, we only draw the line segment between the two points.
$\endgroup$