Did I just find an error in one of the textbook problems? chapter 1 problem 20 of MATLAB An Introduction with Applications, 6th edition.pdf
1 次查看(过去 30 天)
显示 更早的评论
They used the formula to find the area of a parallelogram instead of a triangle.
S=sqrt(s1^2+s2^2+s3^2) finds the area of a parallelogram while S=sqrt(s1^2+s2^2+s3^2)/2 is for a triangle. further more I graphed the 3 points out on a 3d grapher and measured the shortest distance from point p to line ab and it is exactly half the answer you would get if you used the book's formula.
my code:
%% 20)
%define variables
xp=2
yp=6
zp=-1
xa=-2
ya=-1.5
za=-3
xb=-2.5
yb=6
zb=4
r=sqrt((xb-xa)^2+(yb-ya)^2+(zb-za)^2) %solve for r
s1=xp*ya+xa*yb+xb*yp-(yp*xa+ya*xb+yb*xp) % solve for s1,s2,s3; this was fun to type
s2=yp*za+ya*zb+yb*zp-(zp*ya+za*yb+zb*yp)
s3=xp*za+xa*zb+xb*zp-(zp*xa+za*xb+zb*xp)
s=sqrt(s1^2+s2^2+s3^2) %solve for s
d=(2*s)/r %distance can now be calculated
%voila
%d=11.3310 (distance)
%s=58.1920 (triangle area)
graph with distance measured:
11.331/2=5.6655
0 个评论
回答(1 个)
Priysha LNU
2020-10-6
It seems like this is not an official MathWorks text book. You may contact the author of book
MATLAB An Introduction with Applications, 6th edition.pdf
for further clarifications.
DISCLAIMER: These are my own views and in no way depict those of MathWorks.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!