Draw a line with an angle
132 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
we have a point(x,y) and length of the line is L and the angle between horizontal line and the draw line is A.
2 commentaires
Jan
le 30 Juin 2017
Fine. What is your question? What have you tried so far and which problem occurres?
Image Analyst
le 30 Juin 2017
There is a line function you know. Just specify the two endpoints, which can be computed from simple trig.
line([x1,x2], [y1,y2], 'Color', 'r', 'LineWidth', 2);
Réponses (1)
Ahmed raafat
le 29 Juil 2017
%L is the length
%angle is alpha
x2=x+(L*cos(alpha));
y2=y+(L*sin(alpha));
plot([x x2],[y y2])
1 commentaire
Garvit Amipara
le 8 Avr 2021
Modifié(e) : Garvit Amipara
le 8 Avr 2021
This works perfectly!
Note: instead of sin(alpha), cos(alpha), use sind(alpha) and cosd(alpha) to avoid the floating point errors of the sin and cos values.
Voir également
Catégories
En savoir plus sur Hilbert and Walsh-Hadamard Transforms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!