How to plot a curve using angles?

3 views (last 30 days)
Max Payne
Max Payne on 14 Apr 2020
Commented: darova on 15 Apr 2020
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 Comments
darova
darova on 14 Apr 2020
Have angles are defined?
Max Payne
Max Payne on 14 Apr 2020
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!

Sign in to comment.

Accepted Answer

darova
darova on 14 Apr 2020
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 Comments
Max Payne
Max Payne on 15 Apr 2020
The results definitely seem better:
Thank you so much for taking the time to answer my questions.

Sign in to comment.

More Answers (0)

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!