#Generating a regular polygon in code, math is accurate (I think) but edges of poly aren't meeting...

1 messages · Page 1 of 1 (latest)

lusty glacier
#

Picture > 1000 words, so see attached...

Explanation:
Asteroids-like ship shooter and I'm trying to build a polygon-shaped shield around the ship out of 2D sprites. I want to handle collisions and shield-depletion for each segment. I need the shield generator to handle variations in # of sides and distance from the ship.

When I compare the math that I'm doing w/ online calculators the numbers come up right. In other words, a 6-sided poly with sides 1 unit away always ends up with sides 1 unit in length. Variations on those numbers check out, too. When I hit Play and look at the sides , their numbers in the Inspector look good: they are as far away as they need to be and the correct length, but the ends aren't meeting.

Am I missing some basic piece here?

cobalt kiln
lusty glacier
#

You, sir and/or ma'am, may well be right. Investigating now. I see your point, R = radius out to the point, r = radius to center, which is what I want.... back to maths.... brb

cobalt kiln
#

From looking at the grid, it seems you have moved the center of the bar 0.75 units from the center, it should be the corner that should be 0.75 units away and the center should be 0.695…

#

Great pepo_hype

lusty glacier
#

Seems to have been the difference between a SIN and TAN

#

So, like my momma always said, waaaayyyyyyy too much SIN in my life.

cobalt kiln
#

Next time make sure to include the code in your question so it would be easier to help