How to find the edge points of a line in matlab? -
i have plotted line in matlab , want find out coordinates line crosses edges:
any suggestions or advices? =) function xy-limits -1 1. here code far:
yp = -1 + (1-(-1)).*rand(1,2); xp = -1 + (1-(-1)).*rand(1,2); = (yp(2)-yp(1)) / (xp(2)-xp(1)); b = yp(1)-a*xp(1); xlim([-1 1]) ylim([-1 1]) xlims = xlim(gca); ylims = ylim(gca); y = xlims*a+b; line( xlims, y );
- find equation line, ie:
y=a*x+b
- solve x using lower/upper y-limit, if resulting x within x-limits, is/are edge point(s).
- solve y using left/right x-limit, if resulting y within y-limits, is/are edge point(s).
- done
so resulting points within limits green dots in te following picture, resulting points outside limits red ones.
Comments
Post a Comment