geometry.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:xdesign 作者: tomography 项目源码 文件源码
def rotate(self, theta, point=None, axis=None):
        """Rotates the point theta radians around the axis defined by the given
        point and axis."""
        if not isinstance(theta, Number):
            raise TypeError("theta must be scalar.")
        if point is None:
            center = np.zeros(self.dim)
        elif isinstance(point, Point):
            center = point._x
        else:
            raise TypeError("center of rotation must be Point.")
        if axis is not None:
            raise NotImplementedError("Rotation about axis besides [0 0 1] are"
                                      " not implemented.")

        # shift rotation center to origin
        self._x -= center
        # do rotation
        R = np.array([[np.cos(theta), -np.sin(theta)],
                      [np.sin(theta),  np.cos(theta)]])
        self._x = np.dot(R, self._x)
        # shift rotation center back
        self._x += center
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号