Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSpirrwell

Posted 16 November 2012 - 10:52 PM

glVertex2d(0.0 - (FindMissingSide(r, r, 360.0/slices)/2), 0.0 - r);
glVertex2d(0.0 + (FindMissingSide(r, r, 360.0/slices)/2), 0.0 - r);


I think your y values might be the problem.
Your y values are 0-0 - r (the circumRadius)
But what you want is 0-0 - h (the Apothem) - the height of the triangle in your case.

Where h is calculated using pythagoros as:
h = sqrt(pow(r, 2.0) + pow(FindMissingSide(r, r, 360.0/slices)/2, 2.0)

Wikipedia's got a good description of regular polygon's which I found pretty useful. http://en.wikipedia....Regular_polygon

Hope this works.

Matt


Thank you! I could've stared at my work for a year and probably never have noticed that. Since I was thinking circle I thought radius, which would be the same distance from the center in any direction, but because I'm using triangles, that's not true. I guess I accidentally created a faulty syllogism by thinking that way. Again thank you very much! Also, thank you for the extra information, although there was a bug in that one line you gave me: h = sqrt(pow(r, 2.0) + pow(FindMissingSide(r, r, 360.0/slices)/2, 2.0) That plus sign should be a subtraction one. That's at least how I did it...

#1Spirrwell

Posted 16 November 2012 - 10:47 PM

glVertex2d(0.0 - (FindMissingSide(r, r, 360.0/slices)/2), 0.0 - r);
glVertex2d(0.0 + (FindMissingSide(r, r, 360.0/slices)/2), 0.0 - r);


I think your y values might be the problem.
Your y values are 0-0 - r (the circumRadius)
But what you want is 0-0 - h (the Apothem) - the height of the triangle in your case.

Where h is calculated using pythagoros as:
h = sqrt(pow(r, 2.0) + pow(FindMissingSide(r, r, 360.0/slices)/2, 2.0)

Wikipedia's got a good description of regular polygon's which I found pretty useful. http://en.wikipedia....Regular_polygon

Hope this works.

Matt


Thank you! I could've stared at my work for a year and probably never have noticed that. Since I was thinking circle I thought radius, which would be the same distance from the center in any direction, but because I'm using triangles, that's not true. I guess I accidentally created a faulty syllogism by thinking that way. Again thank you very much!

PARTNERS