Hi All,
Imagine the triangle with points ABC is being scaled about its center to the points A2B2C2:
First off, this has been driving me crazy but does the direction/angle each corner will move in have a name? I want to call them corner normals or is the correct term corner bisectors?
Given I am operating in 2D how do I get from knowing points ABC to position B2 given an arbitrary magnitude? Under the hood I want to do this for polygons by walking along the points that define the shape but until I can do it with a triangle I am going to feel like an imbecile.
Here is what I am trying to do now to calculate B2 manually:
// Calculate the vectors
Vector2 vectorA = posA - posB;
Vector2 vectorB = posC - posB;
//Calculate the angle between the vectors and combine them into a single angle
float thetaA = Mathf.Atan2(vectorA.x, vectorA.y);
float thetaB = Mathf.Atan2(vectorB.x, vectorB.y);
float thetaMid = (thetaA + thetaB) / 2;
//Move the point in the direction of the angle by an arbitrary factor so I can visually validate it is correct or not
Vector2 target = new Vector2(posB.x, posB.y);
Move(ref target, 1, thetaMid);
newPosB = target;
SetPositions(posA, posB, posC, newPosB);
public static void Move(ref Vector2 target, float magnitude, float heading) {
target.x += magnitude * Mathf.Cos(heading);
target.y += magnitude * Mathf.Sin(heading);
}
The above code fails as the calculation for the angle is wrong, if you can see why or have a more efficient solution please put me out of my misery!
Kind Regards,
EO