0

i am currently trying to rotate four points to match their Position to an other set of four Points. I do this with a 3D Rotation Matrix. But i get the following issue:

The distance between the points change after the rotation and i do not understand why.

squared_dist = np.sum((tarll-tarul)**2, axis=0)
dist2 = np.sqrt(squared_dist)
print(dist2)

theta = -0.46 

tarlr[0] = tarlr[0] * math.cos(theta) - tarlr[1] * math.sin(theta)
tarlr[1] = tarlr[0] * math.sin(theta) + tarlr[1] * math.cos(theta)
tarlr[2] = tarlr[2]

tarll[0] = tarll[0] * math.cos(theta) - tarll[1] * math.sin(theta)
tarll[1] = tarll[0] * math.sin(theta) + tarll[1] * math.cos(theta)
tarll[2] = tarll[2]

tarur[0] = tarur[0] * math.cos(theta) - tarur[1] * math.sin(theta)
tarur[1] = tarur[0] * math.sin(theta) + tarur[1] * math.cos(theta)
tarur[2] = tarur[2]

tarul[0] = tarul[0] * math.cos(theta) - tarul[1] * math.sin(theta)
tarul[1] = tarul[0] * math.sin(theta) + tarul[1] * math.cos(theta)
tarul[2] = tarul[2]

squared_dist = np.sum((tarll-tarul)**2, axis=0)
dist3 = np.sqrt(squared_dist)
print(dist3)

The points are:

#Tar position
tarlr = np.array([2.5679,3.5465,3.9583]) 
tarur = np.array([5.0263,-0.3365,3.9411]) 
tarul = np.array([1.1462,-2.7898,3.9491]) 
tarll = np.array([-1.3130,1.0835,3.9638]) 

#old  Parameter
tarllOld = np.array([-2.4708,2.3395,4.101]) 
tarlrOld = np.array([2.1218,2.5116,4.0952]) 
tarurOld = np.array([2.2889,-2.0805,4.0774]) 
tarulOld = np.array([-2.2992,-2.2462,4.0859]) 
qwertz
  • 619
  • 1
  • 7
  • 15
  • 6
    Same problem as in [this question](https://stackoverflow.com/questions/56936429/making-a-function-that-translates-a-point-around-another-point/56938681#56938681) – Nico Schertler Jul 24 '19 at 15:44
  • You are overwriting values and than use the changed ones instead of originals for example first line `tarlr[0] = tarlr[0] * ...` and then in second you are using `tarlr[0] ` again but that is already changed which is wrong so buffer the original value or store result in different vector/point .... see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) – Spektre Jul 29 '19 at 11:33

0 Answers0