当前位置: 首页>>代码示例>>Python>>正文


Python Camera.set_autocamera方法代码示例

本文整理汇总了Python中Camera.Camera.set_autocamera方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.set_autocamera方法的具体用法?Python Camera.set_autocamera怎么用?Python Camera.set_autocamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera.Camera的用法示例。


在下文中一共展示了Camera.set_autocamera方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Scene

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import set_autocamera [as 别名]
class Scene():
    def __init__(self, Particles, Camera=None):
        """
        Scene class takes a sphviewer.Particles class and computes the 
        coordinates of the particles as seen from a Camera. It is to say, 
        for a given particle, whose coordinates are x,y and z, Scene 
        computes a new set of coordinates x' and y', which are the aparent 
        coordinates of the particles as seen from a camera. 
        By default, Camera=None means that Scene have to use an autocamera. It 
        will try to define a Camera whose parameters have some sence according
        to your data set. In case you want to prevent Scene from using an autocamera, 
        you should provide a valid Camera Class.
        As Particles class, Scene has its own getting and setting methods.

        setting methods:
        ----------------

        - set_autocamera
        - update_camera

        getting methods:
        ----------------
        - get_scene
        - get_extent

        other methods are: 

        - plot

        """
        try:
            particles_name = Particles._name
        except AttributeError:
            print "You must use a valid Particles class..."
            return
        if(particles_name != 'PARTICLES'):
            print "You must use a valid Particles class..."
            return

        self._name = 'SCENE'
        self._Particles = Particles

        #I use the autocamera by default
        if(Camera==None):
            from Camera import Camera
            self.Camera = Camera()
            self.Camera.set_autocamera(Particles)
            self._camera_params = self.Camera.get_params()

        else:
            try: 
                camera_name = Camera._name
                if(camera_name != 'CAMERA'):
                    print "You must use a valid Camera class..."
                    print "I will try to set an autocamera..."
                    from Camera import Camera
                    self.Camera = Camera()
                    self.Camera.set_autocamera(Particles)
                    self._camera_params = self.Camera.get_params()
                else:
                    self.Camera = Camera
                    self._camera_params = self.Camera.get_params()
            except AttributeError:
                print "You must use a valid Camera class..."
                print "I will try to set an autocamera..."
                from Camera import Camera
                self.Camera = Camera()
                self.Camera.set_autocamera(Particles)
                self._camera_params = self.Camera.get_params()

        self.__x, self.__y, self.__hsml, self.__kview = self.__compute_scene()

    def set_autocamera(self,mode='density'):
        """
        - set_autocamera(mode='density'): By default, Scene defines its 
        own Camera. However, there is no a general way for doing so. Scene 
        uses a density criterion for getting the point of view. If this is 
        not a good option for your problem, you can choose among:
        |'minmax'|'density'|'median'|'mean'|. If None of the previous methods
        work well, you may define the camera params by yourself.
        """
        self.Camera.set_autocamera(self._Particles,mode=mode)
        self._camera_params = self.Camera.get_params()
        self.__x, self.__y, self.__hsml, self.__kview = self.__compute_scene()

    def get_scene(self):
        """
        - get_scene(): It return the x and y position, the smoothing length 
        of the particles and the index of the particles that are active in 
        the scene. In principle this is an internal function and you don't 
        need this data. 
        """
        return self.__x, self.__y, self.__hsml, self.__kview

    def get_extent(self):
        """
        - get_extent(): It returns the extent array needed for converting 
        the image coordinates (given in pixels units) into physical coordinates. 
        It is an array like the following one: [xmin,xmax,ymin,ymax]; it is to say, 
        an array that contains the extreme values of the scene. 
#.........这里部分代码省略.........
开发者ID:yunoshev,项目名称:py-sphviewer,代码行数:103,代码来源:Scene.py


注:本文中的Camera.Camera.set_autocamera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。