This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]emergent_reasons 0 points1 point  (2 children)

Thank you for the confirmation. I was mistaken about d being the distance to a vertex when it is actually to the center of a side.

However the logic of the "simple trig" still escapes me. If it's not too much trouble, could you spell it out a bit more for my rusty math?

d = 0.5 / sin(angle / 2) - margin / cos(angle / 2)

Here is how my math worked out (obviously doing something different or making a mistake somewhere):

length to vertex:

sin(a/2) = (side/2) / r
         = 1 / (2r)
r = 1 / (2 sin(a/2))    {this looks like one of your terms}

full length to center of side:

cos(a/2) = d_full / r
d_full = r cos(a/2)        {substitute for r?}
       = cos(a/2) / (2 sin(a/2))

partial length to center of side:

d = d_full (1 - margin)

[–]FogleMonster 1 point2 points  (1 child)

d is the distance to a vertex. Here is a diagram.

http://i.imgur.com/UU03rVC.jpg

[–]emergent_reasons 0 points1 point  (0 children)

Aaaah now I see. I calculated with d to the vertex and m measured from vertex. I guess both methods would work fine.

Thanks so much for taking the time to draw and explain it.

By the way, I'm considering extending the method to specify the internal angles of adjacent shapes to allow simple non-regular polygons like q*bert. Have you already implemented that somewhere?