I have three joints that make up an arm. They can be in any position.
I find the angle of the middle point using the Law of Cosines. For example in these examples it would be around 115 degrees or so.
http://en.wikipedia.org/wiki/Law_of_cosines
I now need to draw 2 lines (one in each direction) that are half of that angle, so they basically split the triangle in half. Like this.

I found a thread about creating lines at angles here, so I’m using similar code.
http://answers.unity3d.com/questions/350971/how-to-project-an-angle-from-a-vector.html
Now as a test here is my code shooting lines at 0 and 180 and I get this. Seemes pretty odd that they aren’t straight up and down…
pointer.transform.position = (Quaternion.Euler( 0, 0, 0) * bone_lelbow_lhand.transform.up) * range;
pointer2.transform.position = (Quaternion.Euler( 0, 0, -180) * bone_lelbow_lhand.transform.up) * range;
Debug.DrawLine(bone_lelbow_lhand.transform.position, pointer.transform.position, Color.green, 100, true);
Debug.DrawLine(bone_lelbow_lhand.transform.position, pointer2.transform.position, Color.blue, 100, true);
[12129-screen+shot+2013-06-18+at+3.25.03+pm.png|12129]
Anyone have any ideas? I have a feeling I need to use atan2 or align transform.position.up with one of the other joints so the angle appears relative?
My first though about solving this problem would be to use the cross product. Here is a bit of code:
var trA : Transform;
var trB : Transform;
var trC : Transform;
function Update() {
Debug.DrawLine(trB.position, trA.position, Color.green);
Debug.DrawLine(trB.position, trC.position, Color.green);
var v3BA = trA.position - trB.position;
var v3BC = trC.position - trB.position;
var axis = Vector3.Cross(v3BA, v3BC);
var angle = Vector3.Angle(v3BA, v3BC);
var v3 = Quaternion.AngleAxis(angle / 2.0, axis) * v3BA;
Debug.DrawRay(trB.position, v3);
Debug.DrawRay(trB.position, -v3);
}
Attach this script to an empty game object. Put three game objects in the scene and drag and drop them onto the trA, trB, and trC variables. Run the script. You can then move the object around in the inspector while the script is running.
You could also use the Angle Bisector Theorem to find point D on line segment AC where the bisector will intersect. Another example script:
var trA : Transform;
var trB : Transform;
var trC : Transform;
function Update() {
Debug.DrawLine(trB.position, trA.position, Color.green);
Debug.DrawLine(trB.position, trC.position, Color.green);
var v3BA = trA.position - trB.position;
var v3BC = trC.position - trB.position;
var v3AC = trC.position - trA.position;
var v3D = trA.position + v3AC * v3BA.magnitude / (v3BA.magnitude + v3BC.magnitude);
var v3 = v3D - trB.position;
Debug.DrawRay(trB.position, v3);
Debug.DrawRay(trB.position, -v3);
}