I'm trying to write a procedure or function to find the direction in which a 2D triangle points. The triangle is assumed to be isosceles. While I can see the basic outline of what I want to do, making this into a procedure/function is proving harder. This is very basic Mathematica programming, I think... :(
Suppose that points p, q, and r are three arbitrary 2D points assumed to form an isosceles triangle:
triangles =
{
{{30.07, 11.04}, {20.07, 35.905}, {40.905, 19.095}},
{{82.918, 26.9417}, {77.5077, 43.5925}, {88.3281, 43.5925}}}
aTriangle = First[triangles];
{p, q, r} = aTriangle
(*
{{30.07, 11.04}, {20.07, 35.905}, {40.905, 19.095}}
*)
The side lengths are found easily enough:
{EuclideanDistance[p, q],
EuclideanDistance[p, r],
EuclideanDistance[q, r]}
(*
{26.8005, 13.5011, 26.7708}
*)
and clearly in this case pr
is the different side that helps define the direction:
midPoint = {(p[[1]] + r[[1]])/2 , (p[[2]] + r[[2]])/2}
(*
{35.4875, 15.0675}
*)
Then all that's left is to find the angle of the line Line[{midPoint, q}]
, which is probably something like this:
ArcTan[q[[1]] - midPoint[[1]], q[[2]] - midPoint[[2]]] / Degree
(*
126.497
*)
But I want this to be automated, and I can't see how to do this.