input
stringlengths 11
7.65k
| target
stringlengths 22
8.26k
|
---|---|
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def dec_c(self, ind):
r, c = self.row_col(ind)
c -= 1
if c < 0:
c = self.nc - 1
if r == (self.nr - 1) and c == (self.nc - 1):
c = self.nc - 2
return self.indx(r, c) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _setup_drag(self, item):
self._drag_and_drop_context.setup_drag(
item.item_widget,
self._get_drag_data,
self._on_drag_data_received,
[item],
[item],
self) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def row_col(self, ind):
i = 0
for r in range(self.nr):
for c in range(self.nc):
if i == ind:
return r, c
i += 1 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _get_drag_data(self, dragged_item):
return str(self._items.index(dragged_item)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_drag_data_received(self, dragged_item_index_str, destination_item):
dragged_item = self._items[int(dragged_item_index_str)]
self.reorder_item(dragged_item, self._get_item_position(destination_item)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_item_widget_key_press_event(self, widget, event, item):
if event.state & gtk.gdk.MOD1_MASK: # Alt key
key_name = gtk.gdk.keyval_name(event.keyval)
if key_name in ["Up", "KP_Up"]:
self.reorder_item(
item, self._get_item_position(item) - 1)
elif key_name in ["Down", "KP_Down"]:
self.reorder_item(
item, self._get_item_position(item) + 1) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_item_button_remove_clicked(self, button, item):
self.remove_item(item) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _get_item_position(self, item):
return self._items.index(item) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, item_widget):
self._item_widget = item_widget |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def widget(self):
return self._event_box |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def item_widget(self):
return self._item_widget |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def button_remove(self):
return self._button_remove |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def remove_item_widget(self):
self._hbox.remove(self._item_widget) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _setup_item_button(self, item_button, icon, position=None):
item_button.set_relief(gtk.RELIEF_NONE) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_event_box_enter_notify_event(self, event_box, event):
if event.detail != gtk.gdk.NOTIFY_INFERIOR:
self._hbox_buttons.show() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_event_box_leave_notify_event(self, event_box, event):
if event.detail != gtk.gdk.NOTIFY_INFERIOR:
self._hbox_buttons.hide() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_event_box_size_allocate(self, event_box, allocation):
if self._is_event_box_allocated_size:
return |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_event_box_buttons_size_allocate(self, event_box, allocation):
if self._buttons_allocation is not None:
return |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(
self,
new_item_default_value,
min_size=0,
max_size=None,
item_spacing=ItemBox.ITEM_SPACING,
max_width=None,
max_height=None,
*args,
**kwargs):
"""
Parameters: |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _init_gui(self):
self._size_spin_button = gtk.SpinButton(
gtk.Adjustment(
value=0,
lower=self._min_size,
upper=self._max_size,
step_incr=1,
page_incr=10,
),
digits=0) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def add_item(self, item_value=None, index=None):
if item_value is None:
item_value = self._new_item_default_value |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def reorder_item(self, item, new_position):
orig_position = self._get_item_position(item)
processed_new_position = super().reorder_item(item, new_position) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def remove_item(self, item):
if (self._locker.is_unlocked("prevent_removal_below_min_size")
and len(self._items) == self._min_size):
return |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def set_values(self, values):
self._locker.lock("emit_size_spin_button_value_changed")
self._locker.lock("prevent_removal_below_min_size") |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _setup_drag(self, item):
self._drag_and_drop_context.setup_drag(
# Using the entire item allows dragging only by the label rather than the
# widget itself. This avoids problems with widgets such as spin buttons
# that do not behave correctly when reordering and also avoids accidental
# clicking and modifying the widget by the user.
item.widget,
self._get_drag_data,
self._on_drag_data_received,
[item],
[item],
self) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_size_spin_button_value_changed(self, size_spin_button):
if self._locker.is_unlocked("emit_size_spin_button_value_changed"):
self._locker.lock("update_spin_button") |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_item_button_remove_clicked(self, button, item):
self._locker.lock("emit_size_spin_button_value_changed") |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _on_item_widget_size_allocate(self, item_widget, allocation, item):
if item in self._items_allocations:
self._update_width(allocation.width - self._items_allocations[item].width)
self._update_height(allocation.height - self._items_allocations[item].height)
else:
self._update_width(allocation.width)
self._update_height(allocation.height + self._item_spacing) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _update_width(self, width_diff):
if self._items_total_width is None:
self._items_total_width = self.get_allocation().width |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _update_height(self, height_diff):
if self._items_total_height is None:
self._items_total_height = self.get_allocation().height |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _update_dimension(
self,
size_diff,
total_size,
max_visible_size,
dimension_request_property):
if max_visible_size is None:
is_max_visible_size_unlimited = True
else:
is_max_visible_size_unlimited = max_visible_size <= 0 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _rename_item_names(self, start_index):
for index, item in enumerate(self._items[start_index:]):
item.label.set_label(self._get_item_name(index + 1 + start_index)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _get_item_name(index):
return _("Element") + " " + str(index) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, item_widget):
super().__init__(item_widget) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def label(self):
return self._label |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self):
self._tokens = collections.defaultdict(int) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def lock_temp(self, key):
self.lock(key)
try:
yield
finally:
self.unlock(key) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def lock(self, key):
self._tokens[key] += 1 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def unlock(self, key):
if self._tokens[key] > 0:
self._tokens[key] -= 1 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def is_locked(self, key):
return self._tokens[key] > 0 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def is_unlocked(self, key):
return self._tokens[key] == 0 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, backendsdialog):
"""
Constructor, just initializes the gtk widgets
@param backends: a reference to the dialog in which this is
loaded
"""
super().__init__()
self.dialog = backendsdialog
self.req = backendsdialog.get_requester()
self._init_liststore()
self._init_renderers()
self._init_signals()
self.refresh() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def refresh(self):
"""refreshes the Gtk.Liststore"""
self.backendid_to_iter = {}
self.liststore.clear()
# Sort backends
# 1, put default backend on top
# 2, sort backends by human name
backends = list(self.req.get_all_backends(disabled=True))
backends = sorted(backends,
key=lambda backend: (not backend.is_default(),
backend.get_human_name()))
for backend in backends:
self.add_backend(backend)
self.on_backend_state_changed(None, backend.get_id()) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def drawMe(self, g, r):
self.g = g
self.r = r
self.g.save()
self.g.moveTo(self.x,self.y)
self.g.beginPath()
# 根據 r 半徑繪製一個圓代表點的所在位置
self.g.arc(self.x, self.y, self.r, 0, 2*math.pi, true)
self.g.moveTo(self.x,self.y)
self.g.lineTo(self.x+self.r, self.y)
self.g.moveTo(self.x, self.y)
self.g.lineTo(self.x-self.r, self.y)
self.g.moveTo(self.x, self.y)
self.g.lineTo(self.x, self.y+self.r)
self.g.moveTo(self.x, self.y)
self.g.lineTo(self.x, self.y-self.r)
self.g.restore()
self.g.stroke() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def on_backend_added(self, sender, backend_id):
"""
Signal callback executed when a new backend is loaded
@param sender: not used, only here to let this function be used as a
callback
@param backend_id: the id of the backend to add
"""
# Add
backend = self.req.get_backend(backend_id)
if not backend:
return
self.add_backend(backend)
self.refresh()
# Select
self.select_backend(backend_id)
# Update it's enabled state
self.on_backend_state_changed(None, backend.get_id()) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def Eq(self, pt):
self.x = pt.x
self.y = pt.y |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def add_backend(self, backend):
"""
Adds a new backend to the list
@param backend_id: the id of the backend to add
"""
if backend:
backend_iter = self.liststore.append([
backend.get_id(),
self.dialog.get_pixbuf_from_icon_name(backend.get_icon(),
16),
backend.get_human_name(),
self._get_markup_for_tags(backend.get_attached_tags()),
])
self.backendid_to_iter[backend.get_id()] = backend_iter |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setPoint(self, px, py):
self.x = px
self.y = py |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def on_backend_state_changed(self, sender, backend_id):
"""
Signal callback executed when a backend is enabled/disabled.
@param sender: not used, only here to let this function be used as a
callback
@param backend_id: the id of the backend to add
"""
if backend_id in self.backendid_to_iter:
b_iter = self.backendid_to_iter[backend_id]
b_path = self.liststore.get_path(b_iter)
backend = self.req.get_backend(backend_id)
backend_name = backend.get_human_name()
if backend.is_enabled():
text = backend_name
else:
# FIXME This snippet is on more than 2 places!!!
# FIXME create a function which takes a widget and
# flag and returns color as #RRGGBB
style_context = self.get_style_context()
color = style_context.get_color(Gtk.StateFlags.INSENSITIVE)
color = rgba_to_hex(color)
text = f"<span color='{color}'>{backend_name}</span>"
self.liststore[b_path][self.COLUMN_TEXT] = text
# Also refresh the tags
new_tags = self._get_markup_for_tags(backend.get_attached_tags())
self.liststore[b_path][self.COLUMN_TAGS] = new_tags |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def distance(self, pt):
self.pt = pt
x = self.x - self.pt.x
y = self.y - self.pt.y
return math.sqrt(x * x + y * y) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _get_markup_for_tags(self, tag_names):
"""Given a list of tags names, generates the pango markup to render
that list with the tag colors used in GTG
@param tag_names: the list of the tags (strings)
@return str: the pango markup string
"""
if ALLTASKS_TAG in tag_names:
tags_txt = ""
else:
tags_txt = get_colored_tags_markup(self.req, tag_names)
return "<small>" + tags_txt + "</small>" |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def tag(self, g):
self.g = g
self.g.beginPath()
self.g.fillText("%d, %d"%(self.x, self.y),self.x, self.y)
self.g.stroke() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def remove_backend(self, backend_id):
""" Removes a backend from the treeview, and selects the first (to show
something in the configuration panel
@param backend_id: the id of the backend to remove
"""
if backend_id in self.backendid_to_iter:
self.liststore.remove(self.backendid_to_iter[backend_id])
del self.backendid_to_iter[backend_id]
self.select_backend() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
# 直線的第一點, 設為線尾
self.Tail = self.p1
# 直線組成的第二點, 設為線頭
self.Head = self.p2
# 直線的長度屬性
self.length = math.sqrt(math.pow(self.p2.x-self.p1.x, 2)+math.pow(self.p2.y-self.p1.y,2)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _init_liststore(self):
"""Creates the liststore"""
self.liststore = Gtk.ListStore(object, GdkPixbuf.Pixbuf, str, str)
self.set_model(self.liststore) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setPP(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.Tail = self.p1
self.Head = self.p2
self.length = math.sqrt(math.pow(self.p2.x-self.p1.x, 2)+math.pow(self.p2.y-self.p1.y,2)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _init_renderers(self):
"""Initializes the cell renderers"""
# We hide the columns headers
self.set_headers_visible(False)
# For the backend icon
pixbuf_cell = Gtk.CellRendererPixbuf()
tvcolumn_pixbuf = Gtk.TreeViewColumn('Icon', pixbuf_cell)
tvcolumn_pixbuf.add_attribute(pixbuf_cell, 'pixbuf', self.COLUMN_ICON)
self.append_column(tvcolumn_pixbuf)
# For the backend name
text_cell = Gtk.CellRendererText()
tvcolumn_text = Gtk.TreeViewColumn('Name', text_cell)
tvcolumn_text.add_attribute(text_cell, 'markup', self.COLUMN_TEXT)
self.append_column(tvcolumn_text)
text_cell.connect('edited', self.cell_edited_callback)
text_cell.set_property('editable', True)
# For the backend tags
tags_cell = Gtk.CellRendererText()
tvcolumn_tags = Gtk.TreeViewColumn('Tags', tags_cell)
tvcolumn_tags.add_attribute(tags_cell, 'markup', self.COLUMN_TAGS)
self.append_column(tvcolumn_tags) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setRT(self, r, t):
self.r = r
self.t = t
x = self.r * math.cos(self.t)
y = self.r * math.sin(self.t)
self.Tail.Eq(self.p1)
self.Head.setPoint(self.Tail.x + x,self.Tail.y + y) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def cell_edited_callback(self, text_cell, path, new_text):
"""If a backend name is changed, it saves the changes in the Backend
@param text_cell: not used. The Gtk.CellRendererText that emitted the
signal. Only here because it's passed by the signal
@param path: the Gtk.TreePath of the edited cell
@param new_text: the new name of the backend
"""
# we strip everything not permitted in backend names
new_text = ''.join(c for c in new_text if (c.isalnum() or c in [" ", "-", "_"]))
selected_iter = self.liststore.get_iter(path)
# update the backend name
backend_id = self.liststore.get_value(selected_iter,
self.COLUMN_BACKEND_ID)
backend = self.dialog.get_requester().get_backend(backend_id)
if backend:
backend.set_human_name(new_text)
# update the text in the liststore
self.liststore.set(selected_iter, self.COLUMN_TEXT, new_text) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getR(self):
# x 分量與 y 分量
x = self.p1.x - self.p2.x
y = self.p1.y - self.p2.y
return math.sqrt(x * x + y * y) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _init_signals(self):
"""Initializes the backends and gtk signals """
self.connect("cursor-changed", self.on_select_row)
_signals = BackendSignals()
_signals.connect(_signals.BACKEND_ADDED, self.on_backend_added)
_signals.connect(_signals.BACKEND_STATE_TOGGLED,
self.on_backend_state_changed) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getT(self):
x = self.p2.x - self.p1.x
y = self.p2.y - self.p1.y
if (math.fabs(x) < math.pow(10,-100)):
if(y < 0.0):
return (-math.pi/2)
else:
return (math.pi/2)
else:
return math.atan2(y, x) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def on_select_row(self, treeview=None):
"""When a row is selected, displays the corresponding editing panel
@var treeview: not used
"""
self.dialog.on_backend_selected(self.get_selected_backend_id()) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setTail(self, pt):
self.pt = pt
self.Tail.Eq(pt)
self.Head.setPoint(self.pt.x + self.x, self.pt.y + self.y) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _get_selected_path(self):
"""
Helper function to get the selected path
@return Gtk.TreePath : returns exactly one path for the selected object
or None
"""
selection = self.get_selection()
if selection:
model, selected_paths = self.get_selection().get_selected_rows()
if selected_paths:
return selected_paths[0]
return None |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getHead(self):
return self.Head |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def select_backend(self, backend_id=None):
"""
Selects the backend corresponding to backend_id.
If backend_id is none, refreshes the current configuration panel.
@param backend_id: the id of the backend to select
"""
selection = self.get_selection()
if backend_id in self.backendid_to_iter:
backend_iter = self.backendid_to_iter[backend_id]
if selection:
selection.select_iter(backend_iter)
else:
if self._get_selected_path():
# We just reselect the currently selected entry
self.on_select_row()
else:
# If nothing is selected, we select the first entry
if selection:
selection.select_path("0")
self.dialog.on_backend_selected(self.get_selected_backend_id()) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getTail(self):
return self.Tail |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def drawMe(self, g):
self.g = g
self.g.beginPath()
self.g.moveTo(self.p1.x,self.p1.y)
self.g.lineTo(self.p2.x,self.p2.y)
self.g.stroke() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def test(self):
return ("this is pure test to Inherit") |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.length = math.sqrt(math.pow((self.p2.x - self.p1.x), 2) + math.pow((self.p2.y - self.p1.y), 2)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def drawMe(self, g):
self.g = g
hole = 5
radius = 10
length = self.getR()
# alert(length)
# 儲存先前的繪圖狀態
self.g.save()
self.g.translate(self.p1.x,self.p1.y)
#alert(str(self.p1.x)+","+str(self.p1.y))
#self.g.rotate(-((math.pi/2)-self.getT()))
self.g.rotate(-math.pi*0.5 + self.getT())
#alert(str(self.getT()))
#self.g.rotate(10*math.pi/180)
#this.g.rotate(-(Math.PI/2-this.getT()));
# 必須配合畫在 y 軸上的 Link, 進行座標轉換, 也可以改為畫在 x 軸上...
self.g.beginPath()
self.g.moveTo(0,0)
self.g.arc(0, 0, hole, 0, 2*math.pi, true)
self.g.stroke()
self.g.moveTo(0,length)
self.g.beginPath()
self.g.arc(0,length, hole, 0, 2*math.pi, true)
self.g.stroke()
self.g.moveTo(0,0)
self.g.beginPath()
self.g.arc(0,0, radius, 0, math.pi, true)
self.g.moveTo(0+radius,0)
self.g.lineTo(0+radius,0+length)
self.g.stroke()
self.g.moveTo(0,0+length)
self.g.beginPath()
self.g.arc(0, 0+length, radius, math.pi, 0, true)
self.g.moveTo(0-radius,0+length)
self.g.lineTo(0-radius,0)
self.g.stroke()
self.g.restore() |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, p1, p2, p3):
self.p1 = p1
self.p2 = p2
self.p3 = p3 |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getLenp3(self):
p1 = self.p1
ret = p1.distance(self.p2)
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getLenp1(self):
p2 = self.p2
ret = p2.distance(self.p3)
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getLenp2(self):
p1 = self.p1
ret = p1.distance(self.p3)
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getAp1(self):
ret = math.acos(((self.getLenp2() * self.getLenp2() + self.getLenp3() * self.getLenp3()) - self.getLenp1() * self.getLenp1()) / (2* self.getLenp2() * self.getLenp3()))
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getAp2(self):
ret =math.acos(((self.getLenp1() * self.getLenp1() + self.getLenp3() * self.getLenp3()) - self.getLenp2() * self.getLenp2()) / (2* self.getLenp1() * self.getLenp3()))
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getAp3(self):
ret = math.acos(((self.getLenp1() * self.getLenp1() + self.getLenp2() * self.getLenp2()) - self.getLenp3() * self.getLenp3()) / (2* self.getLenp1() * self.getLenp2()))
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def drawMe(self, g):
self.g = g
r = 5
# 繪出三個頂點
self.p1.drawMe(self.g,r)
self.p2.drawMe(self.g,r)
self.p3.drawMe(self.g,r)
line1 = Line(self.p1,self.p2)
line2 = Line(self.p1,self.p3)
line3 = Line(self.p2,self.p3)
# 繪出三邊線
line1.drawMe(self.g)
line2.drawMe(self.g)
line3.drawMe(self.g) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setSSS(self, lenp3, lenp1, lenp2):
self.lenp3 = lenp3
self.lenp1 = lenp1
self.lenp2 = lenp2
self.ap1 = math.acos(((self.lenp2 * self.lenp2 + self.lenp3 * self.lenp3) - self.lenp1 * self.lenp1) / (2* self.lenp2 * self.lenp3))
self.ap2 = math.acos(((self.lenp1 * self.lenp1 + self.lenp3 * self.lenp3) - self.lenp2 * self.lenp2) / (2* self.lenp1 * self.lenp3))
self.ap3 = math.acos(((self.lenp1 * self.lenp1 + self.lenp2 * self.lenp2) - self.lenp3 * self.lenp3) / (2* self.lenp1 * self.lenp2)) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setSAS(self, lenp3, ap2, lenp1):
self.lenp3 = lenp3
self.ap2 = ap2
self.lenp1 = lenp1
self.lenp2 = math.sqrt((self.lenp3 * self.lenp3 + self.lenp1 * self.lenp1) - 2* self.lenp3 * self.lenp1 * math.cos(self.ap2))
#等於 SSS(AB, BC, CA) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setSaSS(self, lenp2, lenp3, lenp1):
self.lenp2 = lenp2
self.lenp3 = lenp3
self.lenp1 = lenp1
if(self.lenp1 > (self.lenp2 + self.lenp3)):
#<CAB 夾角為 180 度, 三點共線且 A 介於 BC 之間
ret = math.pi
else :
# <CAB 夾角為 0, 三點共線且 A 不在 BC 之間
if((self.lenp1 < (self.lenp2 - self.lenp3)) or (self.lenp1 < (self.lenp3 - self.lenp2))):
ret = 0.0
else :
# 透過餘絃定理求出夾角 <CAB
ret = math.acos(((self.lenp2 * self.lenp2 + self.lenp3 * self.lenp3) - self.lenp1 * self.lenp1) / (2 * self.lenp2 * self.lenp3))
return ret |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getSSS(self):
temp = []
temp.append( self.getLenp1() )
temp.append( self.getLenp2() )
temp.append( self.getLenp3() )
return temp |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getAAA(self):
temp = []
temp.append( self.getAp1() )
temp.append( self.getAp2() )
temp.append( self.getAp3() )
return temp |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def getASASAS(self):
temp = []
temp.append(self.getAp1())
temp.append(self.getLenp1())
temp.append(self.getAp2())
temp.append(self.getLenp2())
temp.append(self.getAp3())
temp.append(self.getLenp3())
return temp |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def setPPSS(self, p1, p3, lenp1, lenp3):
temp = []
self.p1 = p1
self.p3 = p3
self.lenp1 = lenp1
self.lenp3 = lenp3
#bp3 is the angle beside p3 point, cp3 is the angle for line23, p2 is the output
line31 = Line(p3, p1)
self.lenp2 = line31.getR()
#self.lenp2 = self.p3.distance(self.p1)
#這裡是求角3
ap3 = math.acos(((self.lenp1 * self.lenp1 + self.lenp2 * self.lenp2) - self.lenp3 * self.lenp3) / (2 * self.lenp1 * self.lenp2))
#ap3 = math.acos(((self.lenp1 * self.lenp1 + self.lenp3 * self.lenp3) - self.lenp2 * self.lenp2) / (2 * self.lenp1 * self.lenp3))
bp3 = line31.getT()
cp3 = bp3 - ap3
temp.append(p3.x + self.lenp1*math.cos(cp3))#p2.x
temp.append(p3.y + self.lenp1*math.sin(cp3))#p2.y
return temp |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def draw():
global theta
context.clearRect(0, 0, canvas.width, canvas.height)
line1.drawMe(context)
line2.drawMe(context)
line3.drawMe(context)
#triangle1.drawMe(context)
#triangle2.drawMe(context)
theta += dx
p2.x = p1.x + line1.length*math.cos(theta*degree)
p2.y = p1.y - line1.length*math.sin(theta*degree)
p3.x, p3.y = triangle2.setPPSS(p2,p4,link2_len,link3_len)
p1.tag(context) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, store):
self.store = store |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, name):
self._name = name |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, x, y):
self.x = x
self.y = y |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def __init__(self, action: str = None) -> None:
super().__init__(prefix, action) |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def draw(self, context):
pass |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def conversion_fn():
"""Temporary function."""
pass |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def _files(self):
return [] |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def no_op(*args, **kwargs):
pass |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def open(read_server_info=True):
return |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def query_vpp_config(self):
NotImplemented |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def tag(g, p):
None |
def dist(a, b):
return sum((i-j)**2 for i, j in zip(a, b)) | def vsParseFd(self, fd):
raise NotImplementedError() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.