[英]What's the idiomatic way to rotate a list of points in np?
Here's a code I use to rotate a 2D vector by 100 degrees: 这是我用来将2D向量旋转100度的代码:
theta = np.deg2rad(100)
c, s = np.cos(theta), np.sin(theta)
R = np.matrix([[c, -s], [s, c]])
V = np.transpose(np.matrix([[1., 1.]]))
Z = np.matmul(R, V)
Is there a built in function for that in numpy? 在numpy中有一个内置函数吗?
In case you are interested in fixed size small vectors I would hardcode the result of the matrix operations and leave it dependent on the cos() and sin(). 如果您对固定大小的小向量感兴趣,我将对矩阵运算的结果进行硬编码,并使其取决于cos()和sin()。 If the matrix are small but a push with the math would be welcome I recommend you to try wxMaxima to get an analytical result to hardcode.
如果矩阵很小,但是欢迎使用数学运算,我建议您尝试使用wxMaxima以获得硬编码的分析结果。 On the other hand, if this is an example targeting bigger vectors I would follow Mihai's suggestion and go for scipy.
另一方面,如果这是针对较大向量的示例,那么我将遵循Mihai的建议并进行研究。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.