0
$\begingroup$

I am writing a software function to plot the outer points of an n-sided polygon and I'm having trouble ensuring I use the correct terminology. The function I've written simply renders the calculated points of a predetermined polygon in two dimensional space. These polygons are neither convex nor concave and thus I believe the name I should give the function is Render Uniform Polygon; however, I believe uniform may not be the correct word and could end up in a debate over the name. The function itself performs three actions to achieve the goal:

  1. Calculate the angle of each point $\theta_n$.
  2. Calculate the new position $P_n$.
  3. Render a 3px by 3px dot at the new position.

The math for calculating $\theta_n$ is:

$$\theta_n = \frac{\biggl(\bigl(\frac{360°}{p}\bigr)n + \phi\biggr)\pi}{180°}$$

Where:

  • $p$ is the number of points in the polygon.
  • $n$ is the current point.
  • $\phi$ is the global rotation angle.

Once $\theta_n$ has been calculated with the math above, I then use it to calculate the new position with the following:

$$P_{_n{x, y}} = C_{x, y} + (\cos(\theta_n), \sin(\theta_n))r$$

Where:

  • $P_n$ is current point's position.
  • $C_{x, y}$ is the center of the polygon.
  • $r$ is the radius of the polygon.

This method can be used to render any polygon with three sides or more, and since the radius is predefined there isn't a case where the polygon can be convex or concave.


What is a polygon that is neither convex nor concave called?

$\endgroup$
5
  • 1
    $\begingroup$ All regular polygons are convex. As far as I know, a polygon that is neither convex nor concave is called "neither convex nor concave". I don't know of any special term for that. $\endgroup$ – Adrian Keister Jan 21 '19 at 18:22
  • $\begingroup$ @AdrianKeister So simply Render Polygon should suffice in this case without causing any confusion? $\endgroup$ – Taco タコス Jan 21 '19 at 18:23
  • 1
    $\begingroup$ Sure! A regular polygon is a polygon, but not the reverse. So if you happen to be constructing regular polygons, a construct_polygon() method is a fine name for that. $\endgroup$ – Adrian Keister Jan 21 '19 at 18:25
  • 2
    $\begingroup$ For me, a concave polygon is one that has at least one angle greater than $\pi$ and a convex one has no angles greater than $\pi$. In that case there are no polygons that are neither concave nor convex. $\endgroup$ – Ross Millikan Jan 21 '19 at 18:25
  • $\begingroup$ @RossMillikan: Excellent point, I agree! $\endgroup$ – Adrian Keister Jan 21 '19 at 18:26
2
$\begingroup$

As far as I can see your polygon is convex. It's a regular polygon whose vertices are equidistant on the circle with radius $r$ and center $C$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.