I have 3 values which I want to represent on a bar graph like display. The catch is I want the bars to come out rotated around a central point, to form a triangular shape. The values are variable, but the total is limited. Something like this.
The values are a, b and c, along vectors o-e, o-g, o-f.
My issue is the math behind it. I can follow the formula easy enough, but have yet to figure out how to apply it correctly in this instance. I'm trying to place point a at the correct distance, then rotate it by 120 degrees(circle/3) to get my three vectors. However, they all shoot off at random angles.
I assume my problem is a) Not getting the direction vectors correct and b) not extending along these correctly. I've looked at wolfram, even the wolfire blog linked in another answer, but can't wrap my head around where I'm going wrong.
Relevant code attached.
var oPos : Vector2 = Vector2(5, 5);
var oAng : Vector2;
var currentAng : float = 0;
var theta : float = 120.0;
var aPos : Vector2;
var aAng : Vector2;
var aDist : int = 7;
var bPos : Vector2;
var bAng : Vector2;
var bDist : int = 7;
var cPos : Vector2;
var cAng : Vector2;
var cDist : int = 7;
private var newAng : Vector2;
private var newPos : Vector2;
function Start()
{
oAng = Vector2(0, 0);
aPos = oPos + Vector2(aDist, aDist);
bPos = oPos + Vector2(bDist, bDist);
bPos.x = (bPos.x * Mathf.Cos(theta)) - (bPos.y * Mathf.Sin(theta));
bPos.y = (bPos.x * Mathf.Sin(theta)) + (bPos.y * Mathf.Cos(theta));
cPos = oPos + Vector2(cDist, cDist);
cPos.x = (cPos.x * Mathf.Cos(theta*2)) - (cPos.y * Mathf.Sin(theta*2));
cPos.y = (cPos.x * Mathf.Sin(theta*2)) + (cPos.y * Mathf.Cos(theta*2));
}