【问题标题】:MATLAB: Math Models for Computer ScienceMATLAB:计算机科学的数学模型
【发布时间】:2014-04-05 03:21:56
【问题描述】:

我有问题需要在 MATLAB 中完成,但在此之前我需要在数学上找到问题的解决方案,问题是:

给出了R^3中的五个点A,B,C,D1,D2。

(a)判断A,B,C三点是否共线(在同一直线上)

(b) 如果 A,B,C 不共线,求包含这三个点的平面

(c)判断D1和D2是否在A,B,C平面内

(d) 如果 D1 AND D2 不在 A,B,C 平面内,求 A,B,C 平面与 D1D2 线的交点

【问题讨论】:

  • 我试图找到 4 行不共线
  • @user3500261: 4 行共线?
  • 抱歉,我找到了 3 个非共线点,这 3 个点确定了一个平面。所以我是这样回答的:
  • 1) N0 2) 我画了图,一个三角形,然后说:A plane contains A,B,C where A,B,C are noncollinear

标签: matlab


【解决方案1】:

如果你花几分钟理解下面的代码sn-p,你也会理解“数学”的解决方案。

// The five points, assumed all distinct.
A = [1 0 0]';
B = [0 1 0]';
C = [0 0  1]';

D1 = [0 0 0]';
D2 = [0.5 0.5 0.5]';

// Not necessary to form the matrix M. Used for convenient plotting.
M = [A B C];

hold on
grid on

// Plot all the points and the line.
for i = 1:3
    plot3(M(1,i), M(2,i), M(3,i), '.', 'MarkerSize', 24)
end
plot3(D1(1), D1(2), D1(3), 'r.', 'MarkerSize', 24)
plot3(D2(1), D2(2), D2(3), 'r.', 'MarkerSize', 24)
plot3([D1(1) D2(1)], [D1(2) D2(2)], [D1(3) D2(3)], 'k', 'LineWidth', 2)
view(120, 20)

// Cross product of B-A and C-A
cp = cross(B-A, C-A);

// Are A, B, and C collinear?
if norm(cp) == 0
    disp('The points are collinear')
else
    disp('The points are not collinear')
    // In this case, find the plane defined by the three points.
    syms x  y z
    plane_eq = [x y z]*cp;
    offset = subs(plane_eq, {x, y, z}, {A(1), A(2), A(3)});
    disp(['The equation of the plane is ' char(plane_eq) ' = ' num2str(offset)])
    u = get(gca, 'XLim');
    v = get(gca, 'YLim');
    h = ezmesh(char(solve(plane_eq - offset, z)), [u v]);
    set(h, 'EdgeColor', [0 0 0], 'FaceColor', 'none')
    if norm((D1-A)'*cp) ~= 0
        disp('D1 does not lie in the plane.')
    end

    if norm((D2-A)'*cp) ~= 0
        disp('D2 does not lie in the plane.')
    end

    M = [D1-D2 B-A C-A];
    b = D1 - A;
    t = inv(M)*b;
    ip = D1 + t(1)*(D2 - D1);
    disp(['The intersection point is [' num2str(ip') '].'])
    plot3(ip(1), ip(2), ip(3), 'g.', 'MarkerSize', 24)

end

还有一些可视化

【讨论】:

    猜你喜欢
    • 2013-01-29
    • 1970-01-01
    • 2017-07-07
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    相关资源
    最近更新 更多