I have been trying to figure out how to write a simple program to compute the x,y points for creating a regular polygon of n sides. Can someone give me some code examples that don't use preexisting functions that draw polygons? I want to understand the process, which I assume is something like this:
- pick an angle to start from a radius and a center point
- somehow calculate the x,y position at that distance from the center(how?)
- divide 360 by the number of sides, move that distance and draw the next line from the first x,y point
- continue until the angle=360 divided by that number.
Assuming that my assumptions are correct, the main thing is to understand how to compute the x,y points.
Prefer answers in a visual basic (or even old style Microsoft/Atari/Commodore BASIC) or a human readable set of steps in English. If you have to answer with a math formula, do it in a computer language so I can read it, even in C or C++ I can figure it out, but I don't know how to read mathematical notation. The language I'm using is a Visual Basic-like language that has almost no graphics primitives other than line drawing.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…