I have a set of x and y points (whatever the function behind) here in black. I would like to move the (x0, y0) point to the (x1,y1) knowing that there is 3 cm (whatever the unit) from (x0, y0) to (x1,y1) at 90° angle.
I would like to do it in Python, however obviously this is pretty bad.
fig = plt.figure()
from mpl_toolkits.mplot3d import Axes3D
ax = fig.add_subplot(111)
c = [55, 53, 54]
d = [29, 27, 27]
c = [55, 53 + 3, 54]
dd = [29, 27 + 3, 27 ]
ax.plot(c,d,'-o', c='g')
ax.plot(c,dd,'-o', c='b')
Partial final answer translated into Python (Thanks to picobit), however I would like to make the picobit function "orientation sensitive" :
fig = plt.figure()
from mpl_toolkits.mplot3d import Axes3D
ax = fig.add_subplot(111)
a = [0.22520001, 0.22140153, 0.21732369, 0.21258711, 0.20764232, 0.20515779,
0.20449048, 0.20467589, 0.20534733]
b = [0.21270538 ,0.21026637, 0.20749939, 0.20383899, 0.19925433, 0.19559762,
0.19440357, 0.19375025, 0.19344115]
dev = [0.0009969 , 0.00143304, 0.00174457, 0.00193148, 0.00199379, 0.00186918,
0.00149534, 0.00087228, 0. ]
import math
def rotate_vector(x0, y0, angle, dev):
magnitude = math.sqrt(x0**2 + y0**2)
xhat = x0/magnitude
yhat = y0/magnitude
x_rot = -yhat * math.sin(angle) + xhat * math.cos(angle)
y_rot = yhat * math.cos(angle) + xhat * math.sin(angle)
x_rot = x_rot * dev
y_rot = y_rot * dev
anglee = 90 # Obviously different if 0 or 45, etc...
x_rot = (x_rot * math.cos(np.radians(anglee))) - (y_rot * math.sin(np.radians(anglee)))
y_rot = (x_rot * math.sin(np.radians(anglee))) + (y_rot * math.cos(np.radians(anglee)))
x_final = x_rot + x0
y_final = y_rot + y0
return x_final, y_final