How can I plot a line just by knowing its angle of inclination and starting point?
19 次查看(过去 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159946/image.png)
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!
0 个评论
回答(1 个)
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
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 Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!