How can I find the angle between a cubic smoothing spline and a line ?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Konstantin Gulin
el 19 de Sept. de 2017
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 comentarios
Clement Prunier
el 20 de Sept. de 2017
Konstantin Gulin
el 20 de Sept. de 2017
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.
Clement Prunier
el 21 de Sept. de 2017
Categorías
Más información sobre Spline Postprocessing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!