def get_svg_data(self, window=[-10, 10], res=1001): x_min = window[0] x_max = window[1] x_left = np.linspace(x_min, self.x0 - (x_max - x_min) / res, res) y_left = self.as_lambda(x_left) x_left = cart_x_to_svg(x_left) y_left = cart_y_to_svg(y_left) x_right = np.linspace(self.x0 + (x_max - x_min) / res, x_max, res) y_right = self.as_lambda(x_right) x_right = cart_x_to_svg(x_right) y_right = cart_y_to_svg(y_right) poly_points = [] current = '' l = len(x_left) i = 0 while i < l: current += f"{x_left[i]},{y_left[i]} " i += 1 poly_points.append(current) current = '' l = len(x_right) i = 0 while i < l: current += f"{x_right[i]},{y_right[i]} " i += 1 poly_points.append(current) # print('poly', poly_points[1]) return {'piecewise': True, 'poly_points': poly_points}
def poly_points_from_nparrays(x, y): x_points = cart_x_to_svg(x) y_points = cart_y_to_svg(y) i = 0 out = "" while i < len(x_points): out += f"{x_points[i]}, {y_points[i]} " i += 1 return out
def get_svg_data(self, window=[-10, 10]): x_min = window[0] x_max = window[1] x_points = np.array([x_min, x_max]) y_points = self.as_lambda(x_points) x_points = cart_x_to_svg(x_points) y_points = cart_y_to_svg(y_points) poly_points = "" l = len(x_points) i = 0 while i < l: poly_points += f"{x_points[i]},{y_points[i]} " i += 1 return poly_points
def get_svg_data(self, window=[-10,10], res=100): x_min = window[0] x_max = window[1] x_points = np.linspace(x_min, x_max, res) # print('x_points', x_points) y_points = self.as_lambda(x_points) x_points = cart_x_to_svg(x_points) y_points = cart_y_to_svg(y_points) poly_points = "" l = len(x_points) i = 0 while i < l: poly_points += f"{x_points[i]},{y_points[i]} " i += 1 return poly_points
def get_svg_data(self, xwindow=[-10, 10], ywindow=[-10, 10]): x_min, x_max = xwindow y_min, y_max = ywindow if self.orientation == 'vert': x_points = np.array([self.value, self.value]) y_points = np.array([y_min, y_max]) else: x_points = np.array([x_min, x_max]) y_points = np.array([self.value, self.value]) x_points = cart_x_to_svg(x_points) y_points = cart_y_to_svg(y_points) poly_points = "" l = len(x_points) i = 0 while i < l: poly_points += f"{x_points[i]},{y_points[i]} " i += 1 return poly_points
def get_svg_data(self, window=[-10,10], res=100): if self.sign_x == 1: x_min = self.x0 x_max = 10 else: x_min = -10 x_max = self.x0 x_points = np.linspace(x_min, x_max, res) y_points = self.as_lambda(x_points) # print(self.as_lambda(self.x)) # print(y_points) x_points = cart_x_to_svg(x_points) y_points = cart_y_to_svg(y_points) poly_points = "" l = len(x_points) i = 0 while i < l: poly_points += f"{x_points[i]},{y_points[i]} " i += 1 return poly_points
def get_svg_data(self, window=[-10, 10], res=100): x_min = -10 - self.x0 x_max = 10 - self.x0 x_points_left = np.linspace(x_min, 0, int(res / 2)) x_points_right = np.linspace(0, x_max, int(res / 2)) x_points = np.concatenate([x_points_left, x_points_right]) x_points = x_points + self.x0 # print(new_lambda(self.x)) y_points_left = -self.m * np.cbrt(-(x_points_left)) + self.y0 y_points_right = self.m * np.cbrt(x_points_right) + self.y0 y_points = np.concatenate([y_points_left, y_points_right]) # print(self.as_lambda(self.x)) # print(y_points) x_points = cart_x_to_svg(x_points) y_points = cart_y_to_svg(y_points) poly_points = "" l = len(x_points) i = 0 while i < l: poly_points += f"{x_points[i]},{y_points[i]} " i += 1 return poly_points