
Triangles
I am attempting to develop a javascript program to calculate the angles of a triangle given
Two Edges and One Angle or Two Angles and One Edge or Three Edges.
The program then displays the triangle angles and edges.
The triangle is drawn using two edges(A&B) and the adjacent angle(C).
see Triangles and Trigonometry
All is fine when given two edges(A&B) and the adjacent angle(C) or three edges
Using these values
I have tested using the edges and angles from entering two edges(A&B) and the adjacent angle(C)
and substituting opposite angles A and B using the same edges A and B when calculating an opposite angle triangle
and likewise for one edge and two angles.
The results make no sense.
the functions I am using(my javascript interpretation of the text book methods) are:
for two edges and an opposite angle
Code:
function zxcEEA(e,a){ // where e is an array of edges and a an opposite angle
e=e.sort(function(b,c){ return bc; }); // to ensure s < 1 e[0] < e[1]
var d2r=Math.PI/180;
var s=e[0]*(Math.sin(a*d2r)/e[1]); // must be < 1
var a2=Math.asin(s)*180/Math.PI; // asin = arcsin
return [a2,180aa2];
}
Code:
for two angles and one edge.
function zxcEAA(e,a1,a2){
e*=1; a1*=1; a2*=1;
var r2d=Math.PI/180,a3=180a1a2,c=e/Math.sin(a1*r2d);
return [c*Math.sin(a2*r2d),c*Math.sin(a3*r2d),a3];
}
I have spent ages on this, any assistane would be appreciated.

Just to say that my script is now working and I have found other posts on this form help full especialy reference documents posted by grandad.