Пример #1
0
    def calculate_segments(self, nbins):
        angles = np.linspace(self.end_angle, self.start_angle, nbins + 1) * np.pi / 180.
        points = np.zeros((nbins+1, 2), dtype=np.float32)
        points[:, 0] = self.radius * np.cos(angles) + self.center[0]
        points[:, 1] = self.radius * np.sin(angles) + self.center[1]

        return math2d.create_segments_from_points(points)
Пример #2
0
    def calculate_segments(self, nbins):
        angles = np.linspace(self.end_angle, self.start_angle,
                             nbins + 1) * np.pi / 180.
        points = np.zeros((nbins + 1, 2), dtype=np.float32)
        points[:, 0] = self.radius * np.cos(angles) + self.center[0]
        points[:, 1] = self.radius * np.sin(angles) + self.center[1]

        return math2d.create_segments_from_points(points)
Пример #3
0
    def calculate_segments(self, nbins):
        points = np.zeros((nbins+1, 2))
        points[:, 1] = np.linspace(-self.width / 2., self.width / 2., nbins+1)
        rot = math2d.angle_matrix(self.angle)
        points = np.dot(points, rot)
        points[:, 0] += self.center[0]
        points[:, 1] += self.center[1]

        return math2d.create_segments_from_points(points)
Пример #4
0
    def calculate_segments(self, nbins):
        points = np.zeros((nbins + 1, 2))
        points[:, 1] = np.linspace(-self.width / 2., self.width / 2.,
                                   nbins + 1)
        rot = math2d.angle_matrix(self.angle)
        points = np.dot(points, rot)
        points[:, 0] += self.center[0]
        points[:, 1] += self.center[1]

        return math2d.create_segments_from_points(points)
Пример #5
0
def create_circle(radius, n_segments=20):
    points = np.zeros((n_segments + 1, 2), dtype=np.float32)
    
    radians = np.linspace(0., 2 * np.pi, n_segments + 1)[:-1][::-1]
    points[:-1, 0] = np.cos(radians) * radius
    points[:-1, 1] = np.sin(radians) * radius

    points[-1] = points[0]
    
    segments = math2d.create_segments_from_points(points)
    
    return Mesh(segments)
Пример #6
0
def create_circle(radius, n_segments=20):
    points = np.zeros((n_segments + 1, 2), dtype=np.float32)

    radians = np.linspace(0., 2 * np.pi, n_segments + 1)[:-1][::-1]
    points[:-1, 0] = np.cos(radians) * radius
    points[:-1, 1] = np.sin(radians) * radius

    points[-1] = points[0]

    segments = math2d.create_segments_from_points(points)

    return Mesh(segments)
Пример #7
0
def create_rectangle(w, h):
    points = np.zeros((5, 2), dtype=np.float32)

    points[0] = [w , h]
    points[1] = [w, -h]
    points[2] = [-w, -h]
    points[3] = [-w, h]
    points[4] = [w, h]
    points /= 2.
    
    segments = math2d.create_segments_from_points(points)
    
    return Mesh(segments)
Пример #8
0
def create_rectangle(w, h):
    points = np.zeros((5, 2), dtype=np.float32)

    points[0] = [w, h]
    points[1] = [w, -h]
    points[2] = [-w, -h]
    points[3] = [-w, h]
    points[4] = [w, h]
    points /= 2.

    segments = math2d.create_segments_from_points(points)

    return Mesh(segments)