blob: a2cf4143e80b7def64e17b31fa8bd14dab6b533e [file] [log] [blame]
Brian Silvermanb0ebf1d2018-10-17 23:36:40 -07001#!/usr/bin/python3
2
Parker Schuhdc682952018-03-03 18:24:01 -08003from __future__ import print_function
Parker Schuh19b93b12018-03-02 23:26:58 -08004import os
5import basic_window
Tabitha Jarvis1007a132018-12-12 21:47:54 -08006from color import Color, palette
Parker Schuhdc682952018-03-03 18:24:01 -08007import random
Parker Schuh19b93b12018-03-02 23:26:58 -08008import gi
9import numpy
10gi.require_version('Gtk', '3.0')
11from gi.repository import Gdk
12import cairo
13import graph_generate
14from graph_generate import XYSegment, AngleSegment, to_theta, to_xy, alpha_blend
15from graph_generate import back_to_xy_loop, subdivide_theta, to_theta_loop
16from graph_generate import l1, l2, joint_center
17
Tabitha Jarvis1007a132018-12-12 21:47:54 -080018from basic_window import OverrideMatrix, identity, quit_main_loop, set_color
Parker Schuh19b93b12018-03-02 23:26:58 -080019
20import shapely
21from shapely.geometry import Polygon
22
Parker Schuhdc682952018-03-03 18:24:01 -080023
Parker Schuh19b93b12018-03-02 23:26:58 -080024def px(cr):
Parker Schuhdc682952018-03-03 18:24:01 -080025 return OverrideMatrix(cr, identity)
Parker Schuh19b93b12018-03-02 23:26:58 -080026
Parker Schuhdc682952018-03-03 18:24:01 -080027
Parker Schuh19b93b12018-03-02 23:26:58 -080028def draw_px_cross(cr, length_px):
Parker Schuhdc682952018-03-03 18:24:01 -080029 """Draws a cross with fixed dimensions in pixel space."""
30 with px(cr):
31 x, y = cr.get_current_point()
32 cr.move_to(x, y - length_px)
33 cr.line_to(x, y + length_px)
34 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -080035
Parker Schuhdc682952018-03-03 18:24:01 -080036 cr.move_to(x - length_px, y)
37 cr.line_to(x + length_px, y)
38 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -080039
Parker Schuhdc682952018-03-03 18:24:01 -080040
Parker Schuh19b93b12018-03-02 23:26:58 -080041def angle_dist_sqr(a1, a2):
Parker Schuhdc682952018-03-03 18:24:01 -080042 """Distance between two points in angle space."""
43 return (a1[0] - a2[0])**2 + (a1[1] - a2[1])**2
44
Parker Schuh19b93b12018-03-02 23:26:58 -080045
46# Find the highest y position that intersects the vertical line defined by x.
47def inter_y(x):
Parker Schuhdc682952018-03-03 18:24:01 -080048 return numpy.sqrt((l2 + l1)**2 -
49 (x - joint_center[0])**2) + joint_center[1]
50
Parker Schuh19b93b12018-03-02 23:26:58 -080051
52# This is the x position where the inner (hyperextension) circle intersects the horizontal line
Parker Schuhdc682952018-03-03 18:24:01 -080053derr = numpy.sqrt((l1 - l2)**2 - (joint_center[1] - 0.3048)**2)
54
Parker Schuh19b93b12018-03-02 23:26:58 -080055
56# Define min and max l1 angles based on vertical constraints.
57def get_angle(boundary):
Parker Schuhdc682952018-03-03 18:24:01 -080058 h = numpy.sqrt((l1)**2 - (boundary - joint_center[0])**2) + joint_center[1]
59 return numpy.arctan2(h, boundary - joint_center[0])
60
Parker Schuh19b93b12018-03-02 23:26:58 -080061
62# left hand side lines
63lines1 = [
Parker Schuhdc682952018-03-03 18:24:01 -080064 (-0.826135, inter_y(-0.826135)),
65 (-0.826135, 0.1397),
66 (-23.025 * 0.0254, 0.1397),
67 (-23.025 * 0.0254, 0.3048),
68 (joint_center[0] - derr, 0.3048),
Parker Schuh19b93b12018-03-02 23:26:58 -080069]
70
71# right hand side lines
Parker Schuhdc682952018-03-03 18:24:01 -080072lines2 = [(joint_center[0] + derr, 0.3048), (0.422275, 0.3048),
73 (0.422275, 0.1397), (0.826135, 0.1397), (0.826135,
74 inter_y(0.826135))]
Parker Schuh19b93b12018-03-02 23:26:58 -080075
Parker Schuhdc682952018-03-03 18:24:01 -080076t1_min = get_angle((32.525 - 4.0) * 0.0254)
77t2_min = -7.0 / 4.0 * numpy.pi
Parker Schuh19b93b12018-03-02 23:26:58 -080078
Parker Schuhdc682952018-03-03 18:24:01 -080079t1_max = get_angle((-32.525 + 4.0) * 0.0254)
80t2_max = numpy.pi * 3.0 / 4.0
81
Parker Schuh19b93b12018-03-02 23:26:58 -080082
83# Draw lines to cr + stroke.
84def draw_lines(cr, lines):
Parker Schuhdc682952018-03-03 18:24:01 -080085 cr.move_to(lines[0][0], lines[0][1])
86 for pt in lines[1:]:
87 cr.line_to(pt[0], pt[1])
88 with px(cr):
89 cr.stroke()
90
Parker Schuh19b93b12018-03-02 23:26:58 -080091
92# Rotate a rasterized loop such that it aligns to when the parameters loop
93def rotate_to_jump_point(points):
Parker Schuhdc682952018-03-03 18:24:01 -080094 last_pt = points[0]
95 for pt_i in range(1, len(points)):
96 pt = points[pt_i]
97 delta = last_pt[1] - pt[1]
98 if abs(delta) > numpy.pi:
Parker Schuhdc682952018-03-03 18:24:01 -080099 return points[pt_i:] + points[:pt_i]
100 last_pt = pt
101 return points
102
Parker Schuh19b93b12018-03-02 23:26:58 -0800103
104# shift points vertically by dy.
105def y_shift(points, dy):
Parker Schuhdc682952018-03-03 18:24:01 -0800106 return [(x, y + dy) for x, y in points]
107
Parker Schuh19b93b12018-03-02 23:26:58 -0800108
109lines1_theta_part = rotate_to_jump_point(to_theta_loop(lines1, 0))
110lines2_theta_part = rotate_to_jump_point(to_theta_loop(lines2))
111
112# Some hacks here to make a single polygon by shifting to get an extra copy of the contraints.
113lines1_theta = y_shift(lines1_theta_part, -numpy.pi * 2) + lines1_theta_part + \
114 y_shift(lines1_theta_part, numpy.pi * 2)
115lines2_theta = y_shift(lines2_theta_part, numpy.pi * 2) + lines2_theta_part + \
116 y_shift(lines2_theta_part, -numpy.pi * 2)
117
118lines_theta = lines1_theta + lines2_theta
119
120p1 = Polygon(lines_theta)
121
Parker Schuhdc682952018-03-03 18:24:01 -0800122p2 = Polygon([(t1_min, t2_min), (t1_max, t2_min), (t1_max, t2_max), (t1_min,
123 t2_max)])
Parker Schuh19b93b12018-03-02 23:26:58 -0800124
125# Fully computed theta constrints.
126lines_theta = list(p1.intersection(p2).exterior.coords)
127
Parker Schuh19b93b12018-03-02 23:26:58 -0800128lines1_theta_back = back_to_xy_loop(lines1_theta)
129lines2_theta_back = back_to_xy_loop(lines2_theta)
130
131lines_theta_back = back_to_xy_loop(lines_theta)
132
Parker Schuhdc682952018-03-03 18:24:01 -0800133
Parker Schuh19b93b12018-03-02 23:26:58 -0800134# Get the closest point to a line from a test pt.
135def get_closest(prev, cur, pt):
Parker Schuhdc682952018-03-03 18:24:01 -0800136 dx_ang = (cur[0] - prev[0])
137 dy_ang = (cur[1] - prev[1])
Parker Schuh19b93b12018-03-02 23:26:58 -0800138
Parker Schuhdc682952018-03-03 18:24:01 -0800139 d = numpy.sqrt(dx_ang**2 + dy_ang**2)
140 if (d < 0.000001):
141 return prev, numpy.sqrt((prev[0] - pt[0])**2 + (prev[1] - pt[1])**2)
142
143 pdx = -dy_ang / d
144 pdy = dx_ang / d
145
146 dpx = pt[0] - prev[0]
147 dpy = pt[1] - prev[1]
148
149 alpha = (dx_ang * dpx + dy_ang * dpy) / d / d
150
151 if (alpha < 0):
152 return prev, numpy.sqrt((prev[0] - pt[0])**2 + (prev[1] - pt[1])**2)
153 elif (alpha > 1):
154 return cur, numpy.sqrt((cur[0] - pt[0])**2 + (cur[1] - pt[1])**2)
155 else:
156 return (alpha_blend(prev[0], cur[0], alpha), alpha_blend(prev[1], cur[1], alpha)), \
157 abs(dpx * pdx + dpy * pdy)
Parker Schuh19b93b12018-03-02 23:26:58 -0800158
159
Parker Schuhdc682952018-03-03 18:24:01 -0800160#
Parker Schuh19b93b12018-03-02 23:26:58 -0800161def closest_segment(lines, pt):
Parker Schuhdc682952018-03-03 18:24:01 -0800162 c_pt, c_pt_dist = get_closest(lines[-1], lines[0], pt)
163 for i in range(1, len(lines)):
164 prev = lines[i - 1]
165 cur = lines[i]
166 c_pt_new, c_pt_new_dist = get_closest(prev, cur, pt)
167 if c_pt_new_dist < c_pt_dist:
168 c_pt = c_pt_new
169 c_pt_dist = c_pt_new_dist
170 return c_pt, c_pt_dist
171
Parker Schuh19b93b12018-03-02 23:26:58 -0800172
173# Create a GTK+ widget on which we will draw using Cairo
174class Silly(basic_window.BaseWindow):
Parker Schuhdc682952018-03-03 18:24:01 -0800175 def __init__(self):
176 super(Silly, self).__init__()
Parker Schuh19b93b12018-03-02 23:26:58 -0800177
Austin Schuhed018082018-07-08 16:01:01 -0700178 self.theta_version = False
Parker Schuhdc682952018-03-03 18:24:01 -0800179 self.reinit_extents()
Parker Schuh19b93b12018-03-02 23:26:58 -0800180
Parker Schuhdc682952018-03-03 18:24:01 -0800181 self.last_pos = (numpy.pi / 2.0, 1.0)
182 self.circular_index_select = -1
Parker Schuh19b93b12018-03-02 23:26:58 -0800183
Parker Schuhdc682952018-03-03 18:24:01 -0800184 # Extra stuff for drawing lines.
185 self.segments = []
186 self.prev_segment_pt = None
187 self.now_segment_pt = None
Austin Schuhee249892018-07-08 16:20:09 -0700188 self.spline_edit = 0
189 self.edit_control1 = True
Parker Schuh19b93b12018-03-02 23:26:58 -0800190
Parker Schuhdc682952018-03-03 18:24:01 -0800191 def reinit_extents(self):
192 if self.theta_version:
193 self.extents_x_min = -numpy.pi * 2
194 self.extents_x_max = numpy.pi * 2
195 self.extents_y_min = -numpy.pi * 2
196 self.extents_y_max = numpy.pi * 2
Parker Schuh19b93b12018-03-02 23:26:58 -0800197 else:
Parker Schuhdc682952018-03-03 18:24:01 -0800198 self.extents_x_min = -40.0 * 0.0254
199 self.extents_x_max = 40.0 * 0.0254
200 self.extents_y_min = -4.0 * 0.0254
201 self.extents_y_max = 110.0 * 0.0254
Parker Schuh19b93b12018-03-02 23:26:58 -0800202
Parker Schuhdc682952018-03-03 18:24:01 -0800203 self.init_extents(
204 (0.5 * (self.extents_x_min + self.extents_x_max), 0.5 *
205 (self.extents_y_max + self.extents_y_min)),
206 (1.0 * (self.extents_x_max - self.extents_x_min), 1.0 *
207 (self.extents_y_max - self.extents_y_min)))
Parker Schuh19b93b12018-03-02 23:26:58 -0800208
Parker Schuhdc682952018-03-03 18:24:01 -0800209 # Handle the expose-event by drawing
210 def handle_draw(self, cr):
211 # use "with px(cr): blah;" to transform to pixel coordinates.
Parker Schuh19b93b12018-03-02 23:26:58 -0800212
Parker Schuhdc682952018-03-03 18:24:01 -0800213 # Fill the background color of the window with grey
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800214 set_color(cr, palette["GREY"])
Parker Schuhdc682952018-03-03 18:24:01 -0800215 cr.paint()
Parker Schuh19b93b12018-03-02 23:26:58 -0800216
Parker Schuhdc682952018-03-03 18:24:01 -0800217 # Draw a extents rectangle
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800218 set_color(cr, palette["WHITE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800219 cr.rectangle(self.extents_x_min, self.extents_y_min,
220 (self.extents_x_max - self.extents_x_min),
221 self.extents_y_max - self.extents_y_min)
222 cr.fill()
Parker Schuh19b93b12018-03-02 23:26:58 -0800223
Parker Schuhdc682952018-03-03 18:24:01 -0800224 if not self.theta_version:
225 # Draw a filled white rectangle.
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800226 set_color(cr, palette["WHITE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800227 cr.rectangle(-2.0, -2.0, 4.0, 4.0)
228 cr.fill()
Parker Schuh19b93b12018-03-02 23:26:58 -0800229
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800230 set_color(cr, palette["BLUE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800231 cr.arc(joint_center[0], joint_center[1], l2 + l1, 0,
232 2.0 * numpy.pi)
233 with px(cr):
234 cr.stroke()
235 cr.arc(joint_center[0], joint_center[1], l1 - l2, 0,
236 2.0 * numpy.pi)
237 with px(cr):
238 cr.stroke()
239 else:
240 # Draw a filled white rectangle.
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800241 set_color(cr, palette["WHITE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800242 cr.rectangle(-numpy.pi, -numpy.pi, numpy.pi * 2.0, numpy.pi * 2.0)
243 cr.fill()
Parker Schuh19b93b12018-03-02 23:26:58 -0800244
Parker Schuhdc682952018-03-03 18:24:01 -0800245 if self.theta_version:
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800246 set_color(cr, palette["BLUE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800247 for i in range(-6, 6):
248 cr.move_to(-40, -40 + i * numpy.pi)
249 cr.line_to(40, 40 + i * numpy.pi)
250 with px(cr):
251 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -0800252
Parker Schuhdc682952018-03-03 18:24:01 -0800253 if self.theta_version:
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800254 set_color(cr, Color(0.5, 0.5, 1.0))
Parker Schuhdc682952018-03-03 18:24:01 -0800255 draw_lines(cr, lines_theta)
256 else:
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800257 set_color(cr, Color(0.5, 1.0, 1.0))
Parker Schuhdc682952018-03-03 18:24:01 -0800258 draw_lines(cr, lines1)
259 draw_lines(cr, lines2)
Parker Schuh19b93b12018-03-02 23:26:58 -0800260
Parker Schuhdc682952018-03-03 18:24:01 -0800261 def get_circular_index(pt):
262 theta1, theta2 = pt
263 circular_index = int(numpy.floor((theta2 - theta1) / numpy.pi))
264 return circular_index
Parker Schuh19b93b12018-03-02 23:26:58 -0800265
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800266 set_color(cr, palette["BLUE"])
Parker Schuhdc682952018-03-03 18:24:01 -0800267 lines = subdivide_theta(lines_theta)
268 o_circular_index = circular_index = get_circular_index(lines[0])
269 p_xy = to_xy(lines[0][0], lines[0][1])
270 if circular_index == self.circular_index_select:
271 cr.move_to(p_xy[0] + circular_index * 0, p_xy[1])
272 for pt in lines[1:]:
273 p_xy = to_xy(pt[0], pt[1])
274 circular_index = get_circular_index(pt)
275 if o_circular_index == self.circular_index_select:
276 cr.line_to(p_xy[0] + o_circular_index * 0, p_xy[1])
277 if circular_index != o_circular_index:
278 o_circular_index = circular_index
279 with px(cr):
280 cr.stroke()
281 if circular_index == self.circular_index_select:
282 cr.move_to(p_xy[0] + circular_index * 0, p_xy[1])
Parker Schuh19b93b12018-03-02 23:26:58 -0800283
Parker Schuhdc682952018-03-03 18:24:01 -0800284 with px(cr):
285 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -0800286
Parker Schuhdc682952018-03-03 18:24:01 -0800287 if not self.theta_version:
288 theta1, theta2 = to_theta(self.last_pos, self.circular_index_select)
289 x, y = joint_center[0], joint_center[1]
290 cr.move_to(x, y)
Parker Schuh19b93b12018-03-02 23:26:58 -0800291
Parker Schuhdc682952018-03-03 18:24:01 -0800292 x += numpy.cos(theta1) * l1
293 y += numpy.sin(theta1) * l1
294 cr.line_to(x, y)
295 x += numpy.cos(theta2) * l2
296 y += numpy.sin(theta2) * l2
297 cr.line_to(x, y)
298 with px(cr):
299 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -0800300
Parker Schuhdc682952018-03-03 18:24:01 -0800301 cr.move_to(self.last_pos[0], self.last_pos[1])
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800302 set_color(cr, Color(0.0, 1.0, 0.2))
Parker Schuhdc682952018-03-03 18:24:01 -0800303 draw_px_cross(cr, 20)
Parker Schuh19b93b12018-03-02 23:26:58 -0800304
Parker Schuhdc682952018-03-03 18:24:01 -0800305 if self.theta_version:
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800306 set_color(cr, Color(0.0, 1.0, 0.2))
Parker Schuhdc682952018-03-03 18:24:01 -0800307 cr.move_to(self.last_pos[0], self.last_pos[1])
308 draw_px_cross(cr, 5)
Parker Schuh19b93b12018-03-02 23:26:58 -0800309
Parker Schuhdc682952018-03-03 18:24:01 -0800310 c_pt, dist = closest_segment(lines_theta, self.last_pos)
311 print("dist:", dist, c_pt, self.last_pos)
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800312 set_color(cr, palette["CYAN"])
Parker Schuhdc682952018-03-03 18:24:01 -0800313 cr.move_to(c_pt[0], c_pt[1])
314 draw_px_cross(cr, 5)
Parker Schuh19b93b12018-03-02 23:26:58 -0800315
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800316 set_color(cr, Color(0.0, 0.5, 1.0))
Parker Schuhdc682952018-03-03 18:24:01 -0800317 for segment in self.segments:
318 color = [0, random.random(), 1]
319 random.shuffle(color)
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800320 set_color(cr, Color(color[0], color[1], color[2]))
Parker Schuhdc682952018-03-03 18:24:01 -0800321 segment.DrawTo(cr, self.theta_version)
322 with px(cr):
323 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -0800324
Tabitha Jarvis1007a132018-12-12 21:47:54 -0800325 set_color(cr, Color(0.0, 1.0, 0.5))
Parker Schuhdc682952018-03-03 18:24:01 -0800326 segment = self.current_seg()
327 if segment:
328 print(segment)
329 segment.DrawTo(cr, self.theta_version)
330 with px(cr):
331 cr.stroke()
Parker Schuh19b93b12018-03-02 23:26:58 -0800332
Parker Schuhdc682952018-03-03 18:24:01 -0800333 def cur_pt_in_theta(self):
334 if self.theta_version: return self.last_pos
335 return to_theta(self.last_pos, self.circular_index_select)
336
337 # Current segment based on which mode the drawing system is in.
338 def current_seg(self):
339 if self.prev_segment_pt and self.now_segment_pt:
340 if self.theta_version:
341 return AngleSegment(self.prev_segment_pt, self.now_segment_pt)
342 else:
343 return XYSegment(self.prev_segment_pt, self.now_segment_pt)
344
345 def do_key_press(self, event):
346 keyval = Gdk.keyval_to_lower(event.keyval)
347 print("Gdk.KEY_" + Gdk.keyval_name(keyval))
348 if keyval == Gdk.KEY_q:
349 print("Found q key and exiting.")
350 quit_main_loop()
351 elif keyval == Gdk.KEY_c:
352 # Increment which arm solution we render
353 self.circular_index_select += 1
354 print(self.circular_index_select)
355 elif keyval == Gdk.KEY_v:
356 # Decrement which arm solution we render
357 self.circular_index_select -= 1
358 print(self.circular_index_select)
359 elif keyval == Gdk.KEY_w:
360 # Add this segment to the segment list.
361 segment = self.current_seg()
362 if segment: self.segments.append(segment)
363 self.prev_segment_pt = self.now_segment_pt
364
365 elif keyval == Gdk.KEY_r:
366 self.prev_segment_pt = self.now_segment_pt
367
368 elif keyval == Gdk.KEY_p:
369 # Print out the segments.
370 print(repr(self.segments))
371 elif keyval == Gdk.KEY_g:
372 # Generate theta points.
373 if self.segments:
374 print(repr(self.segments[0].ToThetaPoints()))
375 elif keyval == Gdk.KEY_e:
376 best_pt = self.now_segment_pt
377 best_dist = 1e10
378 for segment in self.segments:
379 d = angle_dist_sqr(segment.start, self.now_segment_pt)
380 if (d < best_dist):
381 best_pt = segment.start
382 best_dist = d
383 d = angle_dist_sqr(segment.end, self.now_segment_pt)
384 if (d < best_dist):
385 best_pt = segment.end
386 best_dist = d
387 self.now_segment_pt = best_pt
388
389 elif keyval == Gdk.KEY_t:
390 # Toggle between theta and xy renderings
391 if self.theta_version:
392 theta1, theta2 = self.last_pos
393 data = to_xy(theta1, theta2)
394 self.circular_index_select = int(
395 numpy.floor((theta2 - theta1) / numpy.pi))
396 self.last_pos = (data[0], data[1])
397 else:
398 self.last_pos = self.cur_pt_in_theta()
399
400 self.theta_version = not self.theta_version
401 self.reinit_extents()
Austin Schuhee249892018-07-08 16:20:09 -0700402
403 elif keyval == Gdk.KEY_z:
404 self.edit_control1 = not self.edit_control1
405 if self.edit_control1:
406 self.now_segment_pt = self.segments[0].control1
407 else:
408 self.now_segment_pt = self.segments[0].control2
409 if not self.theta_version:
410 data = to_xy(self.now_segment_pt[0], self.now_segment_pt[1])
411 self.last_pos = (data[0], data[1])
412 else:
413 self.last_pos = self.now_segment_pt
414
415 print("self.last_pos: ", self.last_pos, " ci: ",
416 self.circular_index_select)
417
Parker Schuhdc682952018-03-03 18:24:01 -0800418 self.redraw()
419
420 def do_button_press(self, event):
421 self.last_pos = (event.x, event.y)
422 self.now_segment_pt = self.cur_pt_in_theta()
Austin Schuhee249892018-07-08 16:20:09 -0700423
424 if self.edit_control1:
425 self.segments[0].control1 = self.now_segment_pt
426 else:
427 self.segments[0].control2 = self.now_segment_pt
428
Austin Schuh17e484e2018-03-11 01:11:36 -0800429 print('Clicked at theta: %s' % (repr(self.now_segment_pt,)))
Parker Schuhdc682952018-03-03 18:24:01 -0800430 if not self.theta_version:
431 print('Clicked at xy, circular index: (%f, %f, %f)' %
432 (self.last_pos[0], self.last_pos[1],
433 self.circular_index_select))
434
Austin Schuhed018082018-07-08 16:01:01 -0700435 print('c1: numpy.array([%f, %f])' % (self.segments[0].control1[0],
436 self.segments[0].control1[1]))
437 print('c2: numpy.array([%f, %f])' % (self.segments[0].control2[0],
438 self.segments[0].control2[1]))
439
Parker Schuhdc682952018-03-03 18:24:01 -0800440 self.redraw()
441
Parker Schuh19b93b12018-03-02 23:26:58 -0800442
443silly = Silly()
Parker Schuhdc682952018-03-03 18:24:01 -0800444silly.segments = graph_generate.segments
Parker Schuh19b93b12018-03-02 23:26:58 -0800445basic_window.RunApp()