Question Does anyone know how to draw polygon using number of sides and radius in c# winform

Jagadeeesh

New member
Joined
Jul 1, 2021
Messages
1
Programming Experience
Beginner
Does anyone know how to draw polygon using number of sides and radius in c# winform
 
Please post questions in the most appropriate forum. The VS.NET General forum is for general questions about the VS IDE, which this is not. You specify that you want to draw something in WinForms so this thread should have been posted in the Windows Forms forum. I have moved it there.
 
As for the issue, this actually demonstrates very well why beginners often are unable to solve their problems. You are doing what many people do and are treating multiple problems as though they are just one. The first thing to understand is that code is simply an implementation of logic. You should ALWAYS work out what that logic is first, before you try to write the code to implement it. Your question gives no indication that you have made any such effort. What you have asked about is actually a mathematics problem. You should be working out the maths involved first, then turning that into an algorithm, i.e. a list of steps you can follow to get to the desired result. Neither of those two things have anything at all to do with programming, so they are not programming problems, so you don't need any programming knowledge to do them. You should do all that before even trying to write any code. Once you have worked out the maths and formalised the logic, then you can start to write code to implement that logic. At that point, if you encounter an issue, it's a programming problem and we can help you with that. So, you need to put some thought into the maths and the logic and then we can help you with the code part, once you know what the code actually has to do. Your current question is like asking "does anyone know how to build a house" without putting any thought into bricklaying, carpentry, etc, etc.
 
Yes. One way is for you to apply what you learned in geometry to determine how to bisect a circle into a given number of points which will give you an angle. You then apply what you learned in trigonometry to compute the position of a point on a unit circle given an angle. Scale that by the target radius. Store the point position. Increment the angle. Compute the next point. Repeat until you have gone full circle. Now use GDI+ to draw lines between those points.
 
Yes. One way is for you to apply what you learned in geometry to determine how to bisect a circle into a given number of points which will give you an angle. You then apply what you learned in trigonometry to compute the position of a point on a unit circle given an angle. Scale that by the target radius. Store the point position. Increment the angle. Compute the next point. Repeat until you have gone full circle. Now use GDI+ to draw lines between those points.
But who listens to that stuff in maths class because we all know we're never going to use it, right?
 
Back
Top Bottom