2. In this problem, we want to calculate the area of triangle in space using cro
ID: 2257557 • Letter: 2
Question
2. In this problem, we want to calculate the area of triangle in space using cross product of two vectors. (a) The cross product vxu oftwo vectors, v-e,y,VJ and defined as U«U.ur»,), is nte a user-defined function wxproduct (v,u) that determines the cross product of two vectors. The input arguments to the function are two vectors, which can be two- or three-dimensional. (b) Use the function xproduct to determine the cross product of V -(1,3) and (c) Use the function xproduct to determine the cross product of V-(-6,1,3) and U-(5,0,-7) (d) Recall that the magnitude of the cross product Vxu of two vectors, U as two adjacent sides. Thus, the area of triangle having V and U as two adjacent sine, can be interpreted as the area of the parallelogram having V and sides can be calculated by 4sine As Therefore, if A, B, and C are three points in space, the area of a triangle ABC is given by where AB is the vector from point A to point B and AC is the vector from point A to point C. Write a user-defined function yTri xPro(A, B determines the area of tri code that it has two subfunctions xproduct angle formed by the three points A, B, and C. Write the one that determines AB and AC and another (e) Use Tri_XPro to determine the area of a triangle with A (1,2),B and C- (12,-1) -(-5,6) () Use Tri xPro to determine the area of a triangle with 4-(1,2,-3),B-(5,6 2), and C = (12,-1, 2).Explanation / Answer
a)
%% function %%
function w = xproduct (u,v)
l=length(u);
if l==2
u(3)=0;
v(3)=0;
end
w(1)=u(2)*v(3)-u(3)*v(2);
w(2)=-(u(1)*v(3)-u(3)*v(1));
w(3)=u(1)*v(2)-u(2)*v(1);
end
b)
clc;
clear all;
close all;
v=[1 3];
u=[5 -7];
w=xproduct(v,u);
fprintf('cross product of v(1, 3) qnd u(5 ,-7 ) is ');
w
OUTPUT:
cross product of v(1, 3) qnd u(5 ,-7 ) is
w =
0 0 -22
c)
clc;
clear all;
close all;
v=[-6 1 3];
u=[5 0 -7];
w=xproduct(v,u);
fprintf('cross product of v(-6 1 3) qnd u(5 0 -7 ) is ');
w
OUTPUT:
cross product of v(-6 1 3) qnd u(5 0 -7 ) is
w =
-7 -27 -5
d)
%%% function
function y = Tri_xpro(A,B,C);
AB=side(A,B);
BC=side(B,C);
w=xproduct(AB,AC);
y=0.5*sqrt(sum(w.^2));
end
%% subfnction
function g = side (a,b);
g=b-a;
end
e)
%%%
clc;
clear all;
close all;
A=[1 2];
B=[-5,6];
C=[12 -1];
area=Tri_xpro(A,B,C);
fprintf('Area of traingle ABC = %f sq unit ',area);
OUTPUT:
Area of traingle ABC = 13.000000 sq unit
f)
clc;
clear all;
close all;
A=[1 2 -3];
B=[-5,6,2];
C=[12 ,-1, 2];
area=Tri_xpro(A,B,C);
fprintf('Area of traingle ABC = %f sq unit ',area);
OUTPUT:
Area of traingle ABC = 47.765050 sq unit
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.