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


Python geometry.Geometry类代码示例

本文整理汇总了Python中geometry.Geometry的典型用法代码示例。如果您正苦于以下问题:Python Geometry类的具体用法?Python Geometry怎么用?Python Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Initialize

def Initialize(credentials="persistent", opt_url=None):
    """Initialize the EE library.

  If this hasn't been called by the time any object constructor is used,
  it will be called then.  If this is called a second time with a different
  URL, this doesn't do an un-initialization of e.g.: the previously loaded
  Algorithms, but will overwrite them and let point at alternate servers.

  Args:
    credentials: OAuth2 credentials.  'persistent' (default) means use
        credentials already stored in the filesystem, or raise an explanatory
        exception guiding the user to create those credentials.
    opt_url: The base url for the EarthEngine REST API to connect to.
  """
    if credentials == "persistent":
        credentials = _GetPersistentCredentials()
    data.initialize(credentials, (opt_url + "/api" if opt_url else None), opt_url)
    # Initialize the dynamically loaded functions on the objects that want them.
    ApiFunction.initialize()
    Element.initialize()
    Image.initialize()
    Feature.initialize()
    Collection.initialize()
    ImageCollection.initialize()
    FeatureCollection.initialize()
    Filter.initialize()
    Geometry.initialize()
    List.initialize()
    Number.initialize()
    String.initialize()
    Date.initialize()
    Dictionary.initialize()
    Terrain.initialize()
    _InitializeGeneratedClasses()
    _InitializeUnboundMethods()
开发者ID:bevingtona,项目名称:earthengine-api,代码行数:35,代码来源:__init__.py

示例2: Initialize

def Initialize(credentials=None, opt_url=None):
  """Initialize the EE library.

  If this hasn't been called by the time any object constructor is used,
  it will be called then.  If this is called a second time with a different
  URL, this doesn't do an un-initialization of e.g.: the previously loaded
  Algorithms, but will overwrite them and let point at alternate servers.

  Args:
    credentials: OAuth2 credentials.
    opt_url: The base url for the EarthEngine REST API to connect to.
  """
  data.initialize(credentials, (opt_url + '/api' if opt_url else None), opt_url)
  # Initialize the dynamically loaded functions on the objects that want them.
  ApiFunction.initialize()
  Element.initialize()
  Image.initialize()
  Feature.initialize()
  Collection.initialize()
  ImageCollection.initialize()
  FeatureCollection.initialize()
  Filter.initialize()
  Geometry.initialize()
  List.initialize()
  Number.initialize()
  String.initialize()
  Date.initialize()
  Dictionary.initialize()
  _InitializeGeneratedClasses()
  _InitializeUnboundMethods()
开发者ID:Arable,项目名称:ee-python,代码行数:30,代码来源:__init__.py

示例3: __init__

	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)

		#半径
		self.radius = kwargs['radius']

		#角度
		self.angle = kwargs.get('angle', 90.0)

		#圆心
		self.center = (0, 0)

		x = Geometry.sin(self.angle / 2) * self.radius
		y = Geometry.cos(self.angle / 2) * self.radius

		self.source = x, y
		self.target = -x, y

		#外切圆心,外切半径
		if self.angle < 90: #三点求圆
			self.wrap_center = Geometry.circle_center(self.source, self.target, self.center)
			self.wrap_radius = Geometry.distance(self.wrap_center, self.center)
		elif self.angle < 180: #两侧点中点
			self.wrap_center = (0, y)
			self.wrap_radius = x
		else: #所在的圆
			self.wrap_center = self.center
			self.wrap_radius = self.radius
开发者ID:zx013,项目名称:other,代码行数:28,代码来源:shape.py

示例4: Reset

def Reset():
  """Reset the library. Useful for re-initializing to a different server."""
  data.reset()
  ApiFunction.reset()
  Image.reset()
  Feature.reset()
  Collection.reset()
  ImageCollection.reset()
  FeatureCollection.reset()
  Filter.reset()
  Geometry.reset()
  Number.reset()
  String.reset()
  _ResetGeneratedClasses()
  global Algorithms
  Algorithms = _AlgorithmsContainer()
开发者ID:andrewxhill,项目名称:gfw-ee-service,代码行数:16,代码来源:__init__.py

示例5: test_the_hypotenuse

 def test_the_hypotenuse(self):
     Geometry.square = MagicMock(method='square')
     Geometry.square.side_effect = [9, 16]
     
     result = Geometry.hypotenuse(3, 4)
     
     self.assertEqual(result, 5)
开发者ID:JKasakyan,项目名称:CSC-11300-Programming-Languages,代码行数:7,代码来源:test_geometry.py

示例6: __init__

 def __init__(self, universe_material, nbins, diameter=100., detector_width=100., detector='plane'):
     self.universe_material = universe_material
     self.geometry = Geometry()
     self.source = np.array([-diameter / 2., 0.])
     if detector == 'plane':
         self.detector = DetectorPlane([diameter / 2., 0.], detector_width, nbins)
     elif detector == 'arc':
         self.detector = DetectorArc(self.source, diameter, detector_width / 2., -detector_width / 2., nbins)
开发者ID:lynch829,项目名称:PyTracer,代码行数:8,代码来源:simulation.py

示例7: __init__

	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)
		Motion.__init__(self, **kwargs)

		#长度
		self.length = kwargs['length']

		middle = kwargs['middle']
		#中间点,middle=0为圆
		self.middle = (middle, self.length / 2)

		#源点
		self.source = (0, 0)

		#目标点
		if middle:
			self.target = (0, self.length)
		else:
			self.target = self.source

		#圆弧的圆心
		if middle:
			self.center = Geometry.circle_center(self.source, self.target, self.middle)
		else:
			self.center = self.middle

		#半径
		self.radius = Geometry.distance(self.source, self.center)

		#角度
		center_x, center_y = self.center

		if middle > 0:
			self.angle = 360 - 2 * Geometry.acos(center_x / self.radius)
		elif middle < 0:
			self.angle = 2 * Geometry.acos(center_x / self.radius)
		else:
			self.angle = 360

		#距离
		self.distance = Geometry.radian(self.angle) * self.radius

		#上一个点
		self.last_step = self.source
开发者ID:zx013,项目名称:other,代码行数:44,代码来源:route.py

示例8: wrap_collide

	def wrap_collide(self, shape):
		for c1 in self.compose:
			for c2 in shape.compose:
				#先根据扇形和矩形自身的坐标调整
				r1 = self.adjust(c1.adjust(c1.wrap_center)) #用缓存避免重复计算
				r2 = shape.adjust(c2.adjust(c2.wrap_center))
				distance = Geometry.distance(r1, r2)
				if distance < c1.wrap_radius + c2.wrap_radius:
					return True
		return False
开发者ID:zx013,项目名称:other,代码行数:10,代码来源:shape.py

示例9: step

	def step(self, pos, step):
		angle = Geometry.angle(step / self.radius)
		middle = self.middle[0]
		if str(middle)[0] != '-': #逆时针
			angle = 360 - angle
		x, y =  Geometry.rotate(pos, self.center, angle)

		last = self.last_step[0] #上一个位置x的值,用来判断圆形的时候是否超出范围
		self.last_step = x, y

		#每次移动不超过半圈
		if middle * x < 0:
			return self.target
		elif middle == 0:
			if str(middle)[0] != '-':
				if last < 0 and x > 0:
					return self.target
			else:
				if last > 0 and x < 0:
					return self.target
		return x, y
开发者ID:zx013,项目名称:other,代码行数:21,代码来源:route.py

示例10: _calculate_geometry

    def _calculate_geometry(self):
        slot_centers = [bc.center() for bc in self._barcodes]

        # Use empty slots as points if not enough barcodes
        if self.plate_type == Geometry.UNIPUCK:
            use_emptys = len(self._barcodes) < 8
            if use_emptys:
                empty_circles = EmptySlotDetector.detect(self._frame_img, self._barcodes)
                empty_centers = [c.center() for c in empty_circles]
                slot_centers.extend(empty_centers)

        geometry = Geometry.calculate_geometry(self.plate_type, slot_centers)
        return geometry
开发者ID:krisward,项目名称:dls_barcode,代码行数:13,代码来源:scan.py

示例11: __init__

    def __init__(self, render_area):
        self.render_area = render_area

        self.approximation_step = 0
        self.radius = 0

        self.projection_name = "default"

        # Координаты источника света
        self.light_x = 0
        self.light_y = 0
        self.light_z = -1000

        self.geom = Geometry()
开发者ID:katya-malyk,项目名称:sphere_approximation,代码行数:14,代码来源:sphere.py

示例12: from_string

    def from_string(string):
        """ Creates a scan record object from a semi-colon separated string. This is
        used when reading a stored record back from file.
        """
        items = string.strip().split(Record.ITEM_SEPARATOR)
        id = items[Record.IND_ID]
        timestamp = float(items[Record.IND_TIMESTAMP])
        image = items[Record.IND_IMAGE]
        plate_type = items[Record.IND_PLATE]
        barcodes = items[Record.IND_BARCODES].split(Record.BC_SEPARATOR)

        geo_class = Geometry.get_class(plate_type)
        geometry = geo_class.deserialize(items[Record.IND_GEOMETRY])

        return Record(plate_type=plate_type, barcodes=barcodes, timestamp=timestamp,
                      image_path=image, id=id, geometry=geometry)
开发者ID:krisward,项目名称:dls_barcode,代码行数:16,代码来源:record.py

示例13: move

	def move(self):
		for route in self.compose:
			for frame in route.move():
				frame = [self.adjust(route.adjust(pos)) for pos in frame] #根据地图偏移进行调整

				start = frame[0] #起点
				end = frame[-1] #终点
				frame = frame[1:] #包含的帧

				rotate = Geometry.atan((end[0] - start[0]) / (end[1] - start[1])) #方向,可能跳过

				if self.velocity: #角速度为0不旋转
					for rotate_frame in self.turn(rotate):
						yield rotate_frame

				yield {'type': 'move', 'start': start, 'end': end, 'frame': frame}
开发者ID:zx013,项目名称:other,代码行数:16,代码来源:route.py

示例14: turn

	def turn(self, rotate):
		angle = Geometry.standard(rotate - self.toward)
		if not angle:
			return
		direct = self.velocity if angle > 0 else -self.velocity #顺时针或逆时针的步长
		self.residual += abs(angle) #需要旋转的总长度

		start = self.toward
		while self.residual >= self.velocity: #还能再旋转一个时间片
			end = start + direct
			if (end - rotate) * direct > 0:
				end = rotate
			yield {'type': 'rotate', 'start': start, 'end': end}
			self.residual -= self.velocity
			start = end
		self.toward = rotate
开发者ID:zx013,项目名称:other,代码行数:16,代码来源:route.py

示例15: recalculate

    def recalculate(self):
        # Настройка шагов аппроксимации
        circle_count = self.approximation_step
        circle_points_count = self.approximation_step + 2

        # Считаем окружность
        self.geom.clear()
        angle_step = 2*math.pi/circle_points_count
        for circle_number in range(0, circle_count):
            radius_for_point_1 = self.radius * math.sqrt(1 - math.pow((circle_count - (circle_number+1))/circle_count, 2))
            z_axis_for_point_1 = self.radius * (circle_count-(circle_number+1))/circle_count

            radius_for_point_2 = self.radius * math.sqrt(1 - math.pow((circle_count - circle_number)/circle_count, 2))
            z_axis_for_point_2 = self.radius * (circle_count - circle_number) / circle_count

            angle = 0
            while angle < 2*math.pi:
                self.geom.points.append(Geometry.from_polar(radius_for_point_1, angle, z_axis_for_point_1))
                self.geom.points.append(Geometry.from_polar(radius_for_point_1, angle+angle_step, z_axis_for_point_1))
                self.geom.edges.append((len(self.geom.points)-2, len(self.geom.points)-1))

                self.geom.points.append(Geometry.from_polar(radius_for_point_2, angle, z_axis_for_point_2))
                self.geom.points.append(Geometry.from_polar(radius_for_point_2, angle+angle_step, z_axis_for_point_2))
                self.geom.edges.append((len(self.geom.points)-2, len(self.geom.points)-1))

                angle += angle_step

            angle = 2*math.pi
            while angle > 0:
                self.geom.points.append(Geometry.from_polar(radius_for_point_1, angle, -z_axis_for_point_1))
                self.geom.points.append(Geometry.from_polar(radius_for_point_1, angle-angle_step, -z_axis_for_point_1))
                self.geom.edges.append((len(self.geom.points)-2, len(self.geom.points)-1))

                self.geom.points.append(Geometry.from_polar(radius_for_point_2, angle, -z_axis_for_point_2))
                self.geom.points.append(Geometry.from_polar(radius_for_point_2, angle-angle_step, -z_axis_for_point_2))
                self.geom.edges.append((len(self.geom.points)-2, len(self.geom.points)-1))

                angle -= angle_step

        for index in range(0, len(self.geom.points), 4):
            self.geom.faces.append((index, index+1, index+3, index+2))

        self.geom.apply_projection(self.projection_name)
开发者ID:katya-malyk,项目名称:sphere_approximation,代码行数:43,代码来源:sphere.py


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