Finding vectors to create an inner border for a mesh

I’m looking to create an inner border for generated polygons, which function as provinces in my game. As an example:

I have the black vectors, that I use to generate the mesh for the province, and am looking to create the blue vectors from those so that I can then create the red border. It would need to support obtuse and reflex angles as well.

From what I can tell, the best way to do this would be to calculate the angles, get the average of the 2 angles and then place the point along that angle.

In this example that would mean:
float angle1 = Vector2.Angle(C2 - C1, C2 - C3); //Say 40 degrees in this example
float borderangle1 = angle1 / 2; //So 20 degrees

This seems to work correctly, however at this point I’m drawing a blank on how to proceed, just can’t find the right math to take the vector for C2 and the angle, to create the blue vector with the ‘?’ a set distance away from C2 along that angle.

The end game result I’m looking for is something similar to this: https://lh6.ggpht.com/GRHT0lxrGSoF3U-RNiZe5g7Hid8iQvKIftULfG0wAsWOqlun8BIqZdpjHd8UVz8p0EI=h900 in which each province has a coloured inner border.

I looked into some shader solutions to this problem as well, think a mesh is the way to go with this, but could be wrong.

Any help is appreciated, thanks!

Looking at the picture, you seem to have placed the blue dots to the intersection points of the “inner polygon” formed by moving the original one’s edges inwards by “line thickness”, so I guess something like

const float LINE_THICKNESS = 0.3f;

	Vector2 A = new Vector2(0, 0);
	Vector2 B = new Vector2(1, 1);
	Vector2 C = new Vector2(1, 0);

	void Start ()
	{
		// get the "inward direction so we can move the polygon edge inwards
		Vector2 inwards1 = Vector3.Cross(B-A, Vector3.forward).normalized;
		// calculate the start and end to the polygon edge moved inward 
		Vector2 A1 = A + (inwards * LINE_THICKNESS);
		Vector2 B1 = B + (inwards * LINE_THICKNESS);

		// same for the next edge 
		Vector2 inwards2 = Vector3.Cross(C-B, Vector3.forward).normalized;
		Vector2 B2 = A + (inwards * LINE_THICKNESS);
		Vector2 C2 = C + (inwards * LINE_THICKNESS);

		Vector2 newPoint = lineSegmentIntersectionPoint(A1, B1, B2, C2);
	}

Tips on how to make a line segment intersection function was quite easy to find the last time I needed it.

There’s a special case where the edges forming the angle are so parallel and close to each other that the inner line segments don’t intersect. I guess then you could place the new point just right between the A and C…

EDIT: because of negative corners like C1 you should actually check for line intersection, not line segment intersection, since the intersection point in that case is ouside the 2 original line segments.

It seems that you want some sort of miter joint.

One of the posts on this page explains the math behind it pretty well (you have to scroll down a bit).
Here is a diagram from the post I’m talking about. The red dots would be your black dots, and you’d want to find the small black dots on just one side of the line.

alt text

This page contains some more examples.