Hello everybody, i need a polygon formula to draw one. I want to make a function that will draw a polygon , depending on how many vertex's it has. I'm not good at math so i can't figure it out how to do it. Though, i do understand that it should look something like: pass=360/vertex , then calculate some end points of lines that are 'pass' degrees from each other; but i don't know how to do that.
Can someone help?Pls!
Alex_
0
Junior Poster
Recommended Answers
Jump to PostIf my math is correct,
x(n) = x + r*cos(a + n*pass) y(n) = y + r*sin(a + n*pass)
where
0 <= n < vertex
, x and y is the center point, a is the angle of the first point to the right of the …
Jump to PostAlso note that you have to use radians (not degrees) for your angles, so
pass = 2 * M_PI / vertex
(M_PI is in math.h) .
All 8 Replies
nmaillet
97
Posting Whiz in Training
Alex_
commented:
Good formulas!
+1
nucleon
114
Posting Pro in Training
Alex_
commented:
Thank you for telling me about radians!
+1
Alex_
0
Junior Poster
Alex_
0
Junior Poster
Alibeg
1
Junior Poster in Training
Alibeg
1
Junior Poster in Training
Alex_
commented:
Thank you for making clear the formulas!
+1
Alex_
0
Junior Poster
Alibeg
1
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.