Shift and Rotate

Geometry Level pending

Three points in space are given by A = ( 5 , 6 , 10 ) , B = ( 5 , 18 , 26 ) , C = ( 16 , 6 , 10 ) A = (5, 6, 10) , B = (5, 18, 26), C = (-16, 6, 10) . You want to shift these points by the same vector d d , then rotate the resulting points (after the shift) about a certain axis that passes through the origin by a certain angle, such that the final images of the three points are A = ( 1 , 1 , 0 ) , B = ( 1 , 19 , 0 ) , C = ( 22 , 1 , 0 ) A' = (1,1,0) , B' = (1, -19, 0) , C' = (22, 1, 0) .

If the vector d = ( d x , d y , d z ) d = (d_x, d_y, d_z) , find the sum ( d x + d y + d z ) (d_x+d_y+d_z) .


The answer is -23.4.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

David Vreken
Jul 2, 2019

Since rotating the resulting points (after the shift) about a certain axis that passes through the origin results in A A' , B B' , and C C' , the new points after the shift must be the same distance away from the origin as A A' , B B' , and C C' , so:

( 5 + d x ) 2 + ( 6 + d y ) 2 + ( 10 + d z ) 2 = 1 2 + 1 2 + 0 2 (5+d_x)^2+(6+d_y)^2+(10+d_z)^2=1^2+1^2+0^2

( 5 + d x ) 2 + ( 18 + d y ) 2 + ( 26 + d z ) 2 = 1 2 + ( 19 ) 2 + 0 2 (5+d_x)^2+(18+d_y)^2+(26+d_z)^2=1^2+(-19)^2+0^2

( 16 + d x ) 2 + ( 6 + d y ) 2 + ( 10 + d z ) 2 = 2 2 2 + 1 2 + 0 2 (-16+d_x)^2+(6+d_y)^2+(10+d_z)^2=22^2+1^2+0^2

which solves to ( d x , d y , d z ) = ( 6 , 33 5 , 54 5 ) (d_x, d_y, d_z) = (-6, -\frac{33}{5}, -\frac{54}{5}) , so d x + d y + d z = 117 5 = 23.4 d_x + d_y + d_z = -\frac{117}{5} = \boxed{-23.4} .

This is really an outstanding solution. However, I wonder how you managed to solve the three quadratic equations in the three unknowns?

Hosam Hajjir - 1 year, 11 months ago

Log in to reply

Thank you! I subtracted the third equation from the first equation to get ( 16 + d x ) 2 ( 5 + d x ) 2 = 483 (-16 + d_x)^2 - (5 + d_x)^2 = 483 , which solved to d x = 6 d_x = -6 . Then the first two equations become ( 6 + d y ) 2 + ( 10 + d z ) 2 = 1 (6 + d_y)^2 + (10 + d_z)^2 = 1 and ( 18 + d y ) 2 + ( 26 + d z ) 2 = 361 (18 + d_y)^2 + (26 + d_z)^2 = 361 . Solving for d y d_y on the first equation gives d y = 6 ± 1 ( 10 + d z ) 2 d_y = -6 \pm \sqrt{1 - (10 + d_z)^2} , and substituting this in the second equation gives ( 18 + 6 ± 1 ( 10 + d z ) 2 ) 2 + ( 26 + d z ) 2 = 361 (18 + -6 \pm \sqrt{1 - (10 + d_z)^2})^2 + (26 + d_z)^2 = 361 , which simplifies to 25 d z 2 + 540 d z + 2916 = 0 25d_z^2 + 540d_z + 2916 = 0 , which has one repeated root d z = 54 5 d_z = -\frac{54}{5} . Substituting d x = 6 d_x = -6 and d z = 54 5 d_z = -\frac{54}{5} into the first equation gives ( 6 + d y ) 2 = 9 25 (6 + d_y)^2 = \frac{9}{25} and into the second equation gives ( 18 + d y ) 2 = 3249 25 (18 + d_y)^2 = \frac{3249}{25} . Subtracting these equations and solving gives d y = 33 5 d_y = -\frac{33}{5} . Therefore, ( d x , d y , d z ) = ( 6 , 33 5 , 54 5 ) (d_x, d_y, d_z) = (-6, -\frac{33}{5}, -\frac{54}{5}) .

David Vreken - 1 year, 11 months ago
Steven Chase
Jul 2, 2019

Let R R be the rotation matrix. The following relations are described in the problem statement:

R ( A + d ) = A R ( B + d ) = B R ( C + d ) = C R (A + d) = A' \\ R (B + d) = B' \\ R (C + d) = C'

The rotation matrix is defined by an axis and an angle. Let the axis coincide with the unit vector whose components are:

u x = cos θ sin ϕ u y = sin θ sin ϕ u z = cos ϕ u_x = \cos \theta \, \sin \phi \\ u_y = \sin \theta \, \sin \phi \\ u_z = \cos \phi

Let α \alpha be the rotation angle about the axis. The rotation matrix is defined as per the description at the Wikipedia page in the section "Rotation matrix from axis and angle". The equations are also given in the code below.

It is evident from the first set of equations that the rotation matrix effectively determines the d d vector.

d = R 1 A A d = R^{-1} A' - A

I used the following process in conjunction with a hill-climbing algorithm:

1) Move around randomly in ( θ , ϕ , α ) (\theta, \phi, \alpha) space via mutation
2) For each ( θ , ϕ , α ) (\theta, \phi, \alpha) , form a candidate rotation matrix R R
3) From the candidate rotation matrix and the other information, calculate d = R 1 A A d = R^{-1} A' - A
4) Form a residual quantity. residual = R ( B + d ) B + R ( C + d ) C \,\,\,\,\,\, \text{residual} = |R (B + d) - B'| + |R (C + d) - C'|
5) If the most recent mutation results in the smallest residual thus far seen, store the mutated values. Otherwise, reject them
6) This process results in ( d x , d y , d z ) = ( 6.0 , 6.6 , 10.8 ) (d_x,d_y,d_z) = (-6.0, -6.6, -10.8)



Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import math
import random
import numpy as np

##################################################################

# Vector A,B,C components

Ax = 5.0
Ay = 6.0
Az = 10.0

Bx = 5.0
By = 18.0
Bz = 26.0

Cx = -16.0
Cy = 6.0
Cz = 10.0

##################################################################

# Vector A',B',C' components

Apx = 1.0
Apy = 1.0
Apz = 0.0

Bpx = 1.0
Bpy = -19.0
Bpz = 0.0

Cpx = 22.0
Cpy = 1.0
Cpz = 0.0

###################################################################

# Vectors A,B,C,A',B',C'

A = np.array([Ax,Ay,Az])
B = np.array([Bx,By,Bz])
C = np.array([Cx,Cy,Cz])

Ap = np.array([Apx,Apy,Apz])
Bp = np.array([Bpx,Bpy,Bpz])
Cp = np.array([Cpx,Cpy,Cpz])

###################################################################

delta = 0.001  # mutation step

minres = 99999999.0  # cumulative residual

theta = 2.0*math.pi*random.random()   # random parameter initialization
phi = math.pi*random.random()

alpha = 2.0*math.pi*random.random()

count = 0

for j in range(0,2*10**6):   # number of rounds of mutation

    thetam = theta + delta * (-1.0 + 2.0 * random.random())   # mutated values
    phim = phi + delta * (-1.0 + 2.0 * random.random())
    alpham = alpha + delta * (-1.0 + 2.0 * random.random())

    ########

    # unit vector used to form rotation matrix

    ux = math.cos(thetam) * math.sin(phim)
    uy = math.sin(thetam) * math.sin(phim)
    uz = math.cos(phim)

    ########

    # rotation matrix entries

    R11 = math.cos(alpham) + (ux**2.0)*(1.0 - math.cos(alpham))
    R12 = ux*uy*(1.0 - math.cos(alpham)) - uz*math.sin(alpham)
    R13 = ux*uz*(1.0 - math.cos(alpham)) + uy*math.sin(alpham)

    R21 = uy*ux*(1.0 - math.cos(alpham)) + uz*math.sin(alpham)
    R22 = math.cos(alpham) + (uy**2.0)*(1.0 - math.cos(alpham))
    R23 = uy*uz*(1.0 - math.cos(alpham)) - ux*math.sin(alpham)

    R31 = uz*ux*(1.0 - math.cos(alpham)) - uy*math.sin(alpham)
    R32 = uz*uy*(1.0 - math.cos(alpham)) + ux*math.sin(alpham)
    R33 = math.cos(alpham) + (uz**2.0)*(1.0 - math.cos(alpham))

    ########

    # rotation matrix and its inverse

    R =  np.array([[R11,R12,R13],[R21,R22,R23],[R31,R32,R33]])
    Rinv = np.linalg.inv(R)

    ########

    # calculate d vector based on candidate R matrix

    d = np.dot(Rinv,Ap) - A

    ########

    # Calculate residual components from vectors B and C

    Bcheck = np.dot(R,B+d) - Bp
    Ccheck = np.dot(R,C+d) - Cp

    ########

    # residual

    res = np.linalg.norm(Bcheck) + np.linalg.norm(Ccheck)

    ########

    # accept mutated values if cumulative residual gets smaller

    if res < minres:

        minres = res

        theta = thetam 
        phi = phim 
        alpha = alpham

        dx_store = d[0]
        dy_store = d[1]
        dz_store = d[2]

    count = count + 1

    if count%10**6 == 0:
        print count/10**6

##################################################################

print ""
print ""
print minres
print ""
print dx_store
print dy_store
print dz_store
print ""
print (dx_store+dy_store+dz_store)

print ""
print "#######################"
print ""

I think this an unnecessary complication of a simple problem. Please see my solution.

Hosam Hajjir - 1 year, 11 months ago
Hosam Hajjir
Jul 3, 2019

The images of A , B , C A, B, C after the shift and rotation are given by, A = R ( A + d ) , B = R ( B + d ) , C = R ( C + d ) A' = R (A + d) , B' = R (B + d), C' = R(C + d) , where d d is the shift vector and R R is the rotation matrix. Substracting the first from the second, and the first from the third, results in:

[ B A C A ] = R [ B A C A ] [ B' - A' \hspace{12pt} C' - A ' ] = R [ B - A \hspace{12pt} C - A ]

To determine R R we need a third vector on either side of the equation, and for that we can use the cross product, so the equation becomes:

[ B A C A ( B A ) × ( C A ) ] = R [ B A C A ( B A ) × ( C A ) ] [ B' - A' \hspace{12pt} C' - A' \hspace{12pt} (B' - A') \times (C' - A') ] = R [ B - A \hspace{12pt} C - A \hspace{12pt} (B-A) \times (C - A)]

And this is of the form, U = R V U = R V , so we can determine R R by matrix inversion then multiplication, namely, R = U V 1 R = U V^{-1} .

Now that R R is determined, we use any of the first three equations, to determine the vector d d . For example, since A = R ( A + d ) A' = R (A + d) , it follows that d = A + R T A d = -A + R^T A' .

Carrying out the aforementioned operations, results in d = [ 6 , 6.6 , 10.8 ] T d = [-6, -6.6, -10.8]^T ; therefore, ( d x + d y + d z ) = 23.4 (d_x + d_y + d_z) = \boxed{-23.4} .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...