当还有一个常数(不在矩阵中)时,我该如何对矩阵进行加法、乘法?
How do I do addition, multiplication with matrices, when there is a constant (not in a matrix) as well?
我正在尝试(除其他事项外)使用矩阵进行计算。这是我快完成了。
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.array([deltaX,deltaY,deltaZ]).reshape(3,1)
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swerefkoordinates = np.array([x,y,z]).reshape(3,1)
rZ=np.array([cos(omegaZR),sin(omegaZR),0,-sin(omegaZR),cos(omegaZR),0,0,0,1]).reshape(3,3)
rY=np.array([cos(omegaYR),0,-sin(omegaYR),0,1,0,sin(omegaYR),0,cos(omegaYR)]).reshape(3,3)
rX=np.array([1,0,0,0,cos(omegaXR),sin(omegaXR),0,-sin(omegaXR),cos(omegaXR)]).reshape(3,3)
R=np.dot(rZ,rY,rX)
到目前为止一切顺利
下一行计算给我带来了一些麻烦,我的意思是答案错误。
RR92 = deltaXYZ+(delta+1)*np.dot(R,swerefkoordinates)
我正在尝试做的是以下公式(RR92)。
[XYZ] = [deltaX,deltaY,deltaZ]+(1+delta)R[x,y,z]
我很难想象公式(而且我还不允许添加图片)。无论如何,[] 中的内容都是矩阵格式:3 行 1 列。
为了快速得到结果,我将 np.array 转换为矩阵并按如下方式进行计算:
import numpy as np
from numpy import radians, cos, sin, matrix
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.array([deltaX,deltaY,deltaZ]).reshape(3,1)
delXYZ = matrix(deltaXYZ) # matrix
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swerefkoordinates = np.array([x,y,z]).reshape(1,3) # 3*1
swc = matrix(swerefkoordinates) # matrix
rZ=np.array([cos(omegaZR),sin(omegaZR),0,- sin(omegaZR),cos(omegaZR),0,0,0,1]).reshape(3,3)
rY=np.array([cos(omegaYR),0,-sin(omegaYR),0,1,0,sin(omegaYR),0,cos(omegaYR)]).reshape(3,3)
rX=np.array([1,0,0,0,cos(omegaXR),sin(omegaXR),0,-sin(omegaXR),cos(omegaXR)]).reshape(3,3)
R=np.dot(rZ,rY,rX)
mR = matrix(R) # matrix
# finally,
RR92 = delXYZ + (delta+1) * (mR*swc.T) # matrix operatoionz
RR92
# Output
# matrix([[ 3239535.00769073],
# [ 990603.65962255],
# [ 5385205.71977643]])
我设法解决了问题:
from math import *
from numpy import *
import numpy as np
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.matrix([[deltaX],[deltaY],[deltaZ]])
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swc = np.matrix([[x],[y],[z]])
#Rotationsmatrix for Z
rZ=np.matrix([[cos(omegaZR),sin(omegaZR),0],[-sin(omegaZR),cos(omegaZR),0],[0,0,1]])
#Rotationsmatrix for Y
rY=np.matrix([[cos(omegaYR),0,-sin(omegaYR)],[0,1,0],[sin(omegaYR),0,cos(omegaYR)]])
#Rotationsmatrix for X
rX=np.matrix([[1,0,0],[0,cos(omegaXR),sin(omegaXR)],[0,-sin(omegaXR),cos(omegaXR)]]).reshape(3,3)
R=rZ*rY*rX
#calculation
RR92 = deltaXYZ + (delta+1) * (R*swc)
print RR92
正确:
3239535.0069
990625.8659
5385201.6355
我正在尝试(除其他事项外)使用矩阵进行计算。这是我快完成了。
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.array([deltaX,deltaY,deltaZ]).reshape(3,1)
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swerefkoordinates = np.array([x,y,z]).reshape(3,1)
rZ=np.array([cos(omegaZR),sin(omegaZR),0,-sin(omegaZR),cos(omegaZR),0,0,0,1]).reshape(3,3)
rY=np.array([cos(omegaYR),0,-sin(omegaYR),0,1,0,sin(omegaYR),0,cos(omegaYR)]).reshape(3,3)
rX=np.array([1,0,0,0,cos(omegaXR),sin(omegaXR),0,-sin(omegaXR),cos(omegaXR)]).reshape(3,3)
R=np.dot(rZ,rY,rX)
到目前为止一切顺利
下一行计算给我带来了一些麻烦,我的意思是答案错误。
RR92 = deltaXYZ+(delta+1)*np.dot(R,swerefkoordinates)
我正在尝试做的是以下公式(RR92)。
[XYZ] = [deltaX,deltaY,deltaZ]+(1+delta)R[x,y,z]
我很难想象公式(而且我还不允许添加图片)。无论如何,[] 中的内容都是矩阵格式:3 行 1 列。
为了快速得到结果,我将 np.array 转换为矩阵并按如下方式进行计算:
import numpy as np
from numpy import radians, cos, sin, matrix
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.array([deltaX,deltaY,deltaZ]).reshape(3,1)
delXYZ = matrix(deltaXYZ) # matrix
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swerefkoordinates = np.array([x,y,z]).reshape(1,3) # 3*1
swc = matrix(swerefkoordinates) # matrix
rZ=np.array([cos(omegaZR),sin(omegaZR),0,- sin(omegaZR),cos(omegaZR),0,0,0,1]).reshape(3,3)
rY=np.array([cos(omegaYR),0,-sin(omegaYR),0,1,0,sin(omegaYR),0,cos(omegaYR)]).reshape(3,3)
rX=np.array([1,0,0,0,cos(omegaXR),sin(omegaXR),0,-sin(omegaXR),cos(omegaXR)]).reshape(3,3)
R=np.dot(rZ,rY,rX)
mR = matrix(R) # matrix
# finally,
RR92 = delXYZ + (delta+1) * (mR*swc.T) # matrix operatoionz
RR92
# Output
# matrix([[ 3239535.00769073],
# [ 990603.65962255],
# [ 5385205.71977643]])
我设法解决了问题:
from math import *
from numpy import *
import numpy as np
deltaX = -419.375
deltaY = -99.352
deltaZ = -591.349
deltaXYZ = np.matrix([[deltaX],[deltaY],[deltaZ]])
omegaX = 0.850458
omegaY = 1.817245
omegaZ= -7.862245
omegaXR=radians(omegaX/3600)
omegaYR=radians(omegaY/3600)
omegaZR=radians(omegaZ/3600)
delta = (0.99496/(10**6))
x = 3240036.3696
y = 990578.5272
z = 5385763.1648
swc = np.matrix([[x],[y],[z]])
#Rotationsmatrix for Z
rZ=np.matrix([[cos(omegaZR),sin(omegaZR),0],[-sin(omegaZR),cos(omegaZR),0],[0,0,1]])
#Rotationsmatrix for Y
rY=np.matrix([[cos(omegaYR),0,-sin(omegaYR)],[0,1,0],[sin(omegaYR),0,cos(omegaYR)]])
#Rotationsmatrix for X
rX=np.matrix([[1,0,0],[0,cos(omegaXR),sin(omegaXR)],[0,-sin(omegaXR),cos(omegaXR)]]).reshape(3,3)
R=rZ*rY*rX
#calculation
RR92 = deltaXYZ + (delta+1) * (R*swc)
print RR92
正确:
3239535.0069 990625.8659 5385201.6355