In Matlab I've got a point A with coordinates (1,1) and I would like "create" another point B knowing the segment that will link both points (its length and slope between its two vertices, A and B). In other words, by knowing a point (A), a distance and slope value, how can I find the point B?

有帮助吗?

解决方案

Based on the conditions, you would have two points on either side of the line, just at the same distance from A[x1,y1].

Code

%%// PointA Location
x1=1;y1=1;

%%// Demo values
d1 = 5; %%// distance
m = 4/3; %%// slope

%%// Calculations
f1 = d1/sqrt(m.^2+1);
x = [ x1+f1 ; x1-f1]
y = m*(x-x1)+y1

Output

x =
     4
    -2

y =
     5
    -3

其他提示

So with slope m your second point is B=(xB,yB)=(1,1)+(1,m)*t and their distance |AB| is |t|*sqrt(1+m^2). From the second equation you get t and from the first the two possible solutions for positive and negative t.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top