给定3个不共线的点的坐标,指明行数和列数,就可以计算出这个平行四边形内所有元素的坐标。主要利用平行四边形法则和定比分点公式,输出可以是3维数组或者2维数组。
function location = position(ini,m,n)
% ------------------------------------
% This program is used to calculate the position of
% every matrix element in a 3D or 2D plane
%
% A m B
% * * * *
% n * * * *
% * * * *
% * * * *
% C D
%
% Input:
% ini: the initial 3 points of the plane, A B C, row vectors.
% ini must be a 3*3 or 3*2 matrix, for example:[0,0,0; 0,4,4; 4,0,0];
% m: the column of the matrix, say, m=5;
% n: the row of the matrix, say, n=5;
%
% Output:
% pos: 3D vectors. Each slice contains the positions of the row points.
% location: 2D vectors, stored by row.
% ------------------------------------
%% Validation
%Validate the form of ini
form = size(in