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


Python Geometry.from_polar方法代码示例

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


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

示例1: recalculate

# 需要导入模块: from geometry import Geometry [as 别名]
# 或者: from geometry.Geometry import from_polar [as 别名]
    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,代码行数:45,代码来源:sphere.py


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