How can I plot a line just by knowing its angle of inclination and starting point?

20 次查看(过去 30 天)
Hello!
I'm trying to figure out how can I plot a line from the one I only know its angle of inclination with respect of the horizontal and also where it starts. What I'm basically trying to do is to plot the representation of a sphere that emittes light and it goes into a different substance so it gets refracted and with the Snell's Law I know both angles, here's a picture of what I want to mean:
The first image is what I try to mean about the lightbeam, and the second one is what I'm trying to do with the angles, this is so I can put that into a for loop and make the first image. Also I don't know what to do in order that the scale or ruler doesn't move from the first plot which is the black line there stated at zero.
Thanks so much for your help!

回答(1 个)

Walter Roberson
Walter Roberson 2017-1-19
Use the usual: y = m * x + b and m = tan(theta) . With your given start point, solve for b:
y0 = tan(theta) * x0 + b
implies
b = y0 - tan(theta) * x0
  1 个评论
Rawan Alghamdi
Rawan Alghamdi 2019-2-7
Suppose my reference line is between (8,2) and (5,8), and we are trying to draw another line of angle 45 degrees.
How to implement the information you provided.
So, b will be my new point? Then what is my y0?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by