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:
![](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!