How can I find the angle between a cubic smoothing spline and a line ?
2 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
As I started my internship in researching, I started using Matlab in some much more difficult way that I used to in my school, which explain my appearance on your forum.
Here is my problem:
I need to program something which allows me to detect the contact angle of a droplet on a surface. I have already programmed a part which allows me to detect the sides of the droplet, to mark it with some markers, and to get the coordinates of each markers, Then, I used the cubic smoothing spline function in order to get an approximated curve of my sides:
sz2 = size(tabl2);
Size2 = sz2(1);
for it = 1:Size2
Xg(it) = tabl2{it}(1);
Yg(it) = -tabl2{it}(2); % Minus added because of the axis direction
end
Smooth = csaps (Xg,Yg,0.05); % Xg and Yg are basically the coordinates of the left side of my droplet.
I also used a basic polyfit in order to model the contact line.
Here is a picture of the curves I get :

The blue line is my cubic spline, which represent the side of my droplet.
The red line represents the surface, which isn't perfectly straight.
Now I need to get the contact angle between my cubic spline and my contact line, but I am stuck on it, Do you have any ideas?
Thank you very much for you help.
0 件のコメント
採用された回答
John D'Errico
2017 年 9 月 20 日
編集済み: John D'Errico
2017 年 9 月 20 日
You have the smoothing spline. Differentiate the spline. Compute the slope of the spline at the intersection point. You already know the slope of the straight line.
Now it is simple. You have two slopes. Use atan (or atand if you want the angle in degrees) to compute the angles of both curves, with respect to the coordinate axes. Subtract the resulting angles. The difference will be the angle between the curves at the point of intersection.
It is even easier if the straight line is a horizontal line, since then the corresponding angle you would compute is zero.
WTP?
2 件のコメント
その他の回答 (1 件)
Konstantin Gulin
2017 年 9 月 19 日
I would recommend finding the contact vectors for your two curves.
For the spline, take two points; the point of contact [x2 y2] and the point immediately preceding that one [x1 y1].
Generate the vector (you need to add a third dimension, even if it's irrelevant):
v = [(x2 - x1) (y2-y1) 0]
Do the same thing for your line and generate a vector u.
To find the angle between the two use:
Theta = atan2d(norm(cross(u,v)),dot(u,v));
3 件のコメント
Konstantin Gulin
2017 年 9 月 20 日
You can use the Y values from your spline function. For example if your spline is:
s = spline(x,y,xq)
then s(x) will return all the y values in your spline function.
参考
カテゴリ
Help Center および File Exchange で Splines についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!