Reputation: 5
I'm trying to figure out how to get the Height of a triangle:
I have startPoint, endPoint and Length:
Point startPoint = Start.GetPoint();
Point endPoint = End.GetPoint();
double Length = panel.W + startPoint.X;
I already figured out how to get the angle with startPoint and endPoint:
double diffX = endPoint.X - startPoint.X;
double diffY = endPoint.Y - startPoint.Y;
double angleRad = Math.Atan2(diffY, diffX);
double angleDeg = angleRad * (180.0 / Math.PI);
I tried some equations with Math.Cos, Math.Sin and Math.Tan but nothing worked.
So how to get the Height? And also, with only what I have is it possible to get the point (X,Y) at the top of the Height, or, in other words, at the end of the line crossing startPoint and endPoint?
Upvotes: 0
Views: 257
Reputation: 80287
There is no need for arctan/tan mutual annihilation. I assume that the bottom side is horizontal.
Height = abs((endPoint.Y - startPoint.Y) * Length / (endPoint.X - startPoint.X))
VerticeX = StartPoint.X + Length
VerticeY = StartPoint.Y + Height
Upvotes: 2