网站开发到发布,手机医疗网站,wordpress在中国很慢,wordpress 摘要 插件目的#xff1a;在笛卡尔坐标系中#xff0c;已知两个点的位置#xff0c;绘制过这两点的射线。同时射线的长度可以自定义。 一、函数的参数说明
输入参数#xff1a;
PointA#xff1a;射线的起点#xff1b;
PointB#xff1a;射线过的零一点#xff1b;
Length在笛卡尔坐标系中已知两个点的位置绘制过这两点的射线。同时射线的长度可以自定义。 一、函数的参数说明
输入参数
PointA射线的起点
PointB射线过的零一点
Length射线的长度
theta射线的旋转变换角度
color显示的射线颜色。
二、函数的Matlab代码
%% 绘制直线:已知2点的坐标绘制过2点的自定义长度的直线
function DrawLine(PointA,PointB,Length,theta,color)
thetathetagenerate_gaussian_noise_with_variance(1, 1.5);startPointPointA;
% 计算向量差
vector PointB - PointA;
% 归一化向量方向向量
direction_vector vector / norm(vector);% direction_vector 现在是表示P1到P2方向的单位向量% 旋转方向向量
% 旋转矩阵
R [cos(theta*pi/180), -sin(theta*pi/180);sin(theta*pi/180), cos(theta*pi/180)];
% 旋转方向向量
v_rotated R * direction_vector;% 定义一个足够大的长度来表示无限长直线
endPoint PointA Length * v_rotated;
% 绘制直线
line([startPoint(1), endPoint(1)], [startPoint(2), endPoint(2)], Color, color, LineWidth, 2);
hold onend
三、绘制的实例
绘制一条射线起点4,3过点7,9长度10旋转角度0度颜色红色。结果如下