【发布时间】:2013-09-18 12:42:14
【问题描述】:
我有一组点 x,y 和这些指定点的相应角度。我想在这些点上画一条切线,我不知道该怎么做。
http://postimg.org/image/s2y1pqqaj/
如命令窗口所示,第 1 列包含 x 点,第 2 列包含 y 点,第 3 列包含各自的切角。图 1 是 x 和 y 点之间的绘图。 我知道斜率,即每个点的切角,如您在第 3 列中看到的那样。但无法理解如何在这些点上绘制切线。还有切线'y = mx + b'的方程,其中m - 斜率和b是y截距。谢谢你。
这里是代码
% Fill in parr a list of points and tangents to be used for display.
% @param parr (x,y) Array of points.
% @param tan Array of tangents.
% @param lengthStep Distance between points.
function [x y tan] = GetPointListForDisplay(m_Length,r1,r2,count)
global nn ca ce length;
GetLength = m_Length;
length = GetLength;
ca = GetCurvatureAtDeltaLength(0.0);
ce = GetCurvatureAtDeltaLength(length);
%if ((abs(ca) < 1.0/10000.0) && (abs(ce) < 1.0/10000.0))
%end
radius = 1.0 ./ max(abs(ca), abs(ce));
%if (radius < 0.1)
%end
nn = 3 + (180.0 * length/(2*pi*radius)); % Using modified formula of arc here
lengthStep = length/nn;
currLen = -lengthStep;
while (1)
currLen = currLen + lengthStep;
if (currLen > m_Length)
currLen = m_Length;
end
[x,y] = GetPointAtDeltaLength(currLen);
[tan] = GetTangentGridBearingAtDeltaLength(currLen);
z(count,1) = x;
z(count,2)= y;
z(count,3)= tan;
figure(1);
%plot(z(count,1).*sin(z(count,3)),z(count,2).*cos(z(count,3)),'b*');
%plot(z(1,count).*cos(z(3,count)),z(2,count).*sin(z(3,count)),'b*');
plot(z(count,1),z(count,2),'b*');
%plot(z(1,count),z(2,count),'b*');
hold on;
%pause(0.1);
count=count+1;
axis equal;
if (currLen >= m_Length)
z(count,1)= tan
break;
end
end
end
问候,
矿泉水
【问题讨论】:
标签: matlab matlab-figure curve