transfer_functions.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def add_gaussian(self, location, width, height):
        r"""Add a Gaussian distribution to the transfer function.

        Typically, when rendering isocontours, a Guassian distribution is the
        easiest way to draw out features.  The spread provides a softness.
        The values are calculated as :math:`f(x) = h \exp{-(x-x_0)^2 / w}`.

        Parameters
        ----------
        location : float
            The centroid of the Gaussian (:math:`x_0` in the above equation.)
        width : float
            The relative width (:math:`w` in the above equation.)
        height : list of 4 float
            The peak height (:math:`h` in the above equation.)  Note that while
            values greater 1.0 will be accepted, the values of the transmission
            function are clipped at 1.0.  This must be a list, and it is in the
            order of (red, green, blue, alpha).

        Examples
        --------
        This adds a red spike.

        >>> tf = ColorTransferFunction( (-10.0, -5.0) )
        >>> tf.add_gaussian(-9.0, 0.01, [1.0, 0.0, 0.0, 1.0])
        """
        for tf, v in zip(self.funcs, height):
            tf.add_gaussian(location, width, v)
        self.features.append(('gaussian', "location(x):%3.2g" % location, \
                              "width(x):%3.2g" % width, \
                              "height(y):(%3.2g, %3.2g, %3.2g, %3.2g)" % 
                              (height[0], height[1], height[2], height[3])))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号