我猜想这可能不是一个很好的问题,但我完全被困住了,需要一些帮助。
我正在尝试实现这段代码:
一切进展顺利,直到我遇到了这个部分:
我只是在努力理解发生了什么。我不确定作者所指的特定向量投影,或输出格式(该死的鸭子类型)的含义。描述对我来说有点太模糊了。
我正在尝试实现这段代码:
http://www.nathanieltroutman.net/content/calculating-minimum-volume-bounding-box
在C#中,原始代码是Python编写的。一切进展顺利,直到我遇到了这个部分:
def calcProjections(points, *vectors):
"""Calculates the projection of points (NxD) onto the vectors
(MxD) and return the projections p which is a matrix sized (N, M)
where N is the number of points and M is the number of vectors.
p[i][j], is the projection of points[i] onto vectors[j] (which is
between 0 and 1)."""
u = np.array(vectors)
# project the points onto the vectors into on fell swoop
d = np.dot(points, u.T)
# this is the dot product of each vector with itself
v2 = np.diag(np.inner(u, u))
p = d / v2
return p
我只是在努力理解发生了什么。我不确定作者所指的特定向量投影,或输出格式(该死的鸭子类型)的含义。描述对我来说有点太模糊了。
有没有人能提出建议或解释这在做什么?任何帮助都将不胜感激。
谢谢。