Equation of a polygon

365 Views Asked by At

I need a parametric equation for a filled polygon defined by 3 or more points. The closest I've got is by using 3 points in this equation - $polygon = p1 + u(p2-p1) + v(p3-p1)$. But by using points (0,0), (2,1) and (3,1) instead of getting a triangle it makes a parallelogram. Is it possible to define such equation using 3 or more points and getting a filled polygon?

1

There are 1 best solutions below

5
On BEST ANSWER

First, notice that for $t\in [0,1]$, we can make a straight line from any point $p_1$ to $p_2$ by $(1-t)p_1 + tp_2$. So, given $n$ points $p_1,\ldots,p_n$, and $t\in [0,n]$, we just rescale the straight line between each of the pairs of points.

$$f\left(t\right)=\begin{cases} (1-t)p_{1}+tp_{2}, & t\in\left[0,1\right]\\ (2-t)p_{2}+\left(t-1\right)p_{3}, & t\in\left[1,2\right]\\ (3-t)p_{3}+\left(t-2\right)p_{4}, & t\in\left[2,3\right]\\ \vdots & \vdots\\ \left(n-t\right)p_{n}+\left(t-n+1\right)p_{1} & t\in\left[n-1,n\right] \end{cases}$$

So, for you specific example, we would have: $$f\left(t\right)=\begin{cases} \left(0,0\right)+t\left(2,0\right), & t\in\left[0,1\right]\\ (2-t)\left(2,0\right)+\left(t-1\right)\left(2,1\right), & t\in\left[1,2\right]\\ (3-t)\left(2,1\right)+\left(t-2\right)\left(0,0\right), & t\in\left[2,3\right] \end{cases}$$

Hope this helps.