I am trying to programmatically generate beveled edges for two-dimensional polygons. For example, given an array of 4 vertices defining a square, I want to generate something like this:
_________ |\ _____ /| | | | | | | | | | |_____| | |/_______\|
But calculating the vertices of the inner form puzzles me.
Simply creating a copy of the original form and scaling it will not work in the general case. (Imagine trying to skew an N-shaped polygon this way.)
My algorithm so far includes the analysis of adjacent edges (triples of vertices, for example, the lower left, upper left and upper right vertices of a square). From there I need to find the angle between them, and then create a vertex somewhere along this corner, depending on how deep I want the bevel to be.
And because I donβt have so much mathematical background that Iβm stuck. How to find this central corner? Or is there a much simpler way to attack this problem?
source share