Given 3 points in space write a function or functions that will find:
(a) the distance between each of the points
(b) find the angle of each of the verticies making up the triangle
(c) area of the triangle.
Ask for each of the points using the input command,
The input will be 3 points A = (x1,y1,z1), B = (x2,y2,x2), and C = (x3,y3,z3). Figure out a way to check your answer.
A = [10 6 -9];
B = [5 -8 1];
C = [-4 6 -2];
[AB,BC,CA] = FindDistance(A,B,C)
[A1,B1,C1] = FindAngles(AB,BC,CA)
[Area] = FindTriangleArea(AB,BC,CA,A1)
Functions
function [AB,BC,CA] = FindDistance(A,B,C)
AB1 = B-A;
BC1 = C-B;
CA1 = A-C;
AB = sqrt(sum(dot(AB1,AB1)));
BC = sqrt(sum(dot(BC1,BC1)));
CA = sqrt(sum(dot(CA1,CA1)));
end
function [A1,B1,C1] = FindAngles(AB,BC,CA)
B1 = acosd(BC/AB);
A1 = acosd(CA/AB);
C1 = 180-B1-A1;
end
function [Area] = FindTriangleArea(AB,BC,CA,A1)
b = AB;
h = CA*sind(A1)
Area = (1/2)*b*h
end
Our instructor gave us predetermined verticies. I am having a lot of trouble with finding the angles and finding the area of the triangle. My function that finds the length of each side works perfectly, but I can not seem to figure out why my other two functions are not working. I'm assuming my Area function is wrong because my Angle function is wrong.
Anyways, if anyone can edit my code and give a breif explanation on why its wrong that would be great. Any help will be great, you do not have to go through and edit everything, just one fix will help.
Also, if you can find already pre-made functions that I can look at to help me write my own, please paste the link in this thread.
Thank you so much!!!