How to plot a curve using angles?

14 ビュー (過去 30 日間)
Max Payne
Max Payne 2020 年 4 月 14 日
コメント済み: darova 2020 年 4 月 15 日
I want to plot the 2D curve that passes through a number of points for which I only have the angle (inclination of the curve with respect to the vertical) and the length of the line between each two points. The form of the line should be a spline in order to get a smooth curve of the coordinates y with respect to the coordinates x. Here's an example of the data I have:
s = linspace[0,1000,100]; % Each entry of this vector represents the location of the respctive point on the curve
Inc = linspace[0,1.5708,100] % This is only an example that shuould describe a quadrant, whereas the actual angles that I have are not as perfect
My goal is to get the actual values of x and y for any given point along the curve. Suppose the curve starts from the origin [0,0].
The result obtained from the above data should be your usual quadrant, or something close.
P.S. I'm not all that familiar with MATLAB so please don't leave out any details.
Thanks in advance.
  2 件のコメント
darova
darova 2020 年 4 月 14 日
Have angles are defined?
Max Payne
Max Payne 2020 年 4 月 14 日
As I stated in the question, the angles represent the inclination of the curve with respect to the vetical axis at each respective point so similar to your 1st drawing. Something like this:
Thanks!

サインインしてコメントする。

採用された回答

darova
darova 2020 年 4 月 14 日
Try cumsum
ds = rand(1,10); % length of each segment
a = rand(1,10)*90; % angle of each segment
dx = sind(a).*ds; % projection of segment on X axis
dy = cosd(a).*ds; % projection of segment on Y axis
x = [0 cumsum(dx)];
y = [0 cumsum(dy)];
plot(x,y)
See more about cumsum
>> cumsum([1 0 2 1])
ans =
1 1 3 4
  6 件のコメント
Max Payne
Max Payne 2020 年 4 月 15 日
The results definitely seem better:
Thank you so much for taking the time to answer my questions.
darova
darova 2020 年 4 月 15 日
my plesure

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by