本文整理汇总了Python中Geometry类的典型用法代码示例。如果您正苦于以下问题:Python Geometry类的具体用法?Python Geometry怎么用?Python Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Geometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_scroll_continuous
def do_scroll_continuous(self, hand):
hand_normal_direction = Geometry.to_vector(hand.palm_normal)
hand_direction = Geometry.to_vector(hand.direction)
roll = hand_normal_direction.roll()
pitch = hand_normal_direction.pitch()
velocity = self.convert_angles_to_mouse_velocity(roll, pitch) * 100
self.cursor.scroll(velocity[0], velocity[1])
示例2: UpdateLigandAnchorPoint
def UpdateLigandAnchorPoint(self):
try:
if self.Translation:
index = int(float(self.Line[self.colNo:self.colNo+10]))
coordX = self.top.GridVertex[index][0] # The atom X coordinate
coordY = self.top.GridVertex[index][1] # The atom Y coordinate
coordZ = self.top.GridVertex[index][2] # The atom Z coordinate
pointA = [coordX, coordY, coordZ]
pointB = [self.top.OriX[0], self.top.OriX[1], self.top.OriX[2]]
pointC = [self.top.Ori[0], self.top.Ori[1], self.top.Ori[2]]
pointD = [self.top.OriY[0], self.top.OriY[1], self.top.OriY[2]]
self.top.DisAngDih[self.top.VarAtoms[0]][0] = Geometry.distance(pointA, pointB)
self.top.DisAngDih[self.top.VarAtoms[0]][1] = Geometry.angle(pointA, pointB, pointC)
self.top.DisAngDih[self.top.VarAtoms[0]][2] = Geometry.dihedralAngle(pointA, pointB, pointC, pointD)
self.colNo += 11
if self.Rotation:
self.top.DisAngDih[self.top.VarAtoms[1]][1] = float(self.Line[self.colNo:self.colNo+10])
self.top.DisAngDih[self.top.VarAtoms[1]][2] = float(self.Line[self.colNo+11:self.colNo+21])
self.top.DisAngDih[self.top.VarAtoms[2]][2] = float(self.Line[self.colNo+22:self.colNo+32])
self.colNo += 33
except:
self.CriticalError(" Could not update ligand anchor point")
return 1
return 0
示例3: do_mouse_stuff
def do_mouse_stuff(self, hand): #Take a hand and use it as a mouse
hand_normal_direction = Geometry.to_vector(hand.palm_normal)
hand_direction = Geometry.to_vector(hand.direction)
roll = hand_normal_direction.roll()
pitch = hand_normal_direction.pitch()
mouse_velocity = self.convert_angles_to_mouse_velocity(roll, pitch)
self.cursor.move(mouse_velocity[0], mouse_velocity[1])
示例4: kinect_to_cartesian
def kinect_to_cartesian(kinect_pos, calib):
top_dist = Geometry.distFromPointToLine(kinect_pos, calib.ul, calib.ur)
bot_dist = Geometry.distFromPointToLine(kinect_pos, calib.ul, calib.ur)
left_dist = Geometry.distFromPointToLine(kinect_pos, calib.ul, calib.ur)
right_dist = Geometry.distFromPointToLine(kinect_pos, calib.ul, calib.ur)
h = []
示例5: make_accepting
def make_accepting(self, state):
print("Accept Fired")
is_accepting = self.parser.add_accepting(state)
if is_accepting:
state.accept_button.configure(bg=ACCEPTING)
else:
state.accept_button.configure(bg=NONE)
is_entry = self.parser.is_entry(state)
Geometry.make_accepting(self.canvas_window, state, is_accepting, is_entry)
示例6: has_two_pointer_fingers
def has_two_pointer_fingers(hand): #Checks if we are using two pointer fingers
if len(hand.fingers) < 2: #Obviously not
return False
sorted_fingers = sort_fingers_by_distance_from_screen(hand.fingers)
finger1_pos = Geometry.to_vector(sorted_fingers[0].tip_position)
finger2_pos = Geometry.to_vector(sorted_fingers[1].tip_position)
difference = finger1_pos - finger2_pos
if difference.norm() < 40: #Check if the fingertips are close together
return True
else:
return False
示例7: has_thumb
def has_thumb(hand): #The level of accuracy with this function is surprisingly high
if hand.fingers.empty: #We assume no thumbs
return False
distances = []
palm_position = Geometry.to_vector(hand.palm_position)
for finger in hand.fingers: #Make a list of all distances from the center of the palm
finger_position = Geometry.to_vector(finger.tip_position)
difference = finger_position - palm_position
distances.append(difference.norm()) #Record the distance from the palm to the fingertip
average = sum(distances)/len(distances)
minimum = min(distances)
if average - minimum > 20: #Check if the finger closest to the palm is more than 20mm closer than the average distance
return True
else:
return False
示例8: collides
def collides(self,p):
#print Geometry.distance(self.x,self.y,p.x,p.y), self.r
if Geometry.distance(self.x,self.y,p.x,p.y) < self.r:
p.kill()
return True
else:
return False
示例9: evolve
def evolve(self):
""" Run evolution.
"""
pop_size = 100
seeds = []
seed = []
for aa in self.sequence:
geo = Geometry.geometry(aa)
seed.append(geo.phi)
seed.append(geo.psi_im1)
template_seeds = self.create_seeds(self.path + "/pdbs2")
seeds += template_seeds
seeds += [seed for x in range(100 - len(template_seeds))]
self.es.terminator = terminators.evaluation_termination
self.es.evolve(generator=self.generator,
evaluator=self.eval_func,
pop_size=pop_size,
maximize=False,
max_evaluations=2000000000,
bounder=self.bounder,
seeds=seeds,
neighborhood_size=10,
cognitive_rate=1,
social_rate=1,
num_inputs=self.c_size)
示例10: on_AddNPolygonButton_clicked
def on_AddNPolygonButton_clicked(self, widget):
N = int(Gtk.Entry.get_text(self.NSidesEntry))
Radius = float(Gtk.Entry.get_text(self.NRadiusEntry))
Center = tuple(map(int, Gtk.Entry.get_text(self.NCenterEntry).split(",")))
Angle = float(Gtk.Entry.get_text(self.NAngleEntry))
Polygon = Geometry.n_Sided_Polygon(N, Radius, Center, Angle)
self.Shapes.append(Polygon)
示例11: build_all_angles_model
def build_all_angles_model(pdb_filename):
parser=PDBParser()
structure=parser.get_structure('sample', \
path.join(PDBdir, pdb_filename))
model=structure[0]
chain=model['A']
model_structure_geo=[]
prev="0"
N_prev="0"
CA_prev="0"
CO_prev="0"
prev_res=""
rad=180.0/math.pi
for res in chain:
if(res.get_resname() in resdict.keys()):
geo=Geometry.geometry(resdict[res.get_resname()])
if(prev=="0"):
N_prev=res['N']
CA_prev=res['CA']
C_prev=res['C']
prev="1"
else:
n1=N_prev.get_vector()
ca1=CA_prev.get_vector()
c1=C_prev.get_vector()
C_curr=res['C']
N_curr=res['N']
CA_curr=res['CA']
c=C_curr.get_vector()
n=N_curr.get_vector()
ca=CA_curr.get_vector()
geo.CA_C_N_angle=calc_angle(ca1, c1, n)*rad
geo.C_N_CA_angle=calc_angle(c1, n, ca)*rad
psi= calc_dihedral(n1, ca1, c1, n) ##goes to current res
omega= calc_dihedral(ca1, c1, n, ca) ##goes to current res
phi= calc_dihedral(c1, n, ca, c) ##goes to current res
geo.psi_im1=psi*rad
geo.omega=omega*rad
geo.phi=phi*rad
geo.N_CA_C_angle= calc_angle(n, ca, c)*rad
##geo.CA_C_O_angle= calc_angle(ca, c, o)*rad
##geo.N_CA_C_O= calc_dihedral(n, ca, c, o)*rad
N_prev=res['N']
CA_prev=res['CA']
C_prev=res['C']
##O_prev=res['O']
model_structure_geo.append(geo)
return model_structure_geo
示例12: mouseMovement
def mouseMovement(self, x, y):
return Geometry.rotate2d((x, y), math.radians(self._mapRotation))
if self.current == Constants.N:
return (x, y)
elif self.current == Constants.NW:
return Geometry.rotate2d((x, y), math.radians(-45))
elif self.current == Constants.E:
return (-y, x)
elif self.current == Constants.NE:
return Geometry.rotate2d((-y, x), math.radians(-45))
elif self.current == Constants.S:
return (-x, -y)
elif self.current == Constants.SE:
return Geometry.rotate2d((-x, -y), math.radians(-45))
elif self.current == Constants.W:
return (y, -x)
else:
return Geometry.rotate2d((y, -x), math.radians(-45))
示例13: add_state
def add_state(self):
new_state_name = self.control_window.state_entry.get()
print(new_state_name)
self.control_window.state_entry.delete(0, END)
self.states.append(State(self.control_window.frame, new_state_name))
new_state = self.states[-1]
new_state.state_label.grid(row=len(self.states), column=0)
new_state.transition_button.configure(text="TRANSITION", command=lambda : self.transition(new_state))
new_state.transition_button.grid(row=len(self.states), column=1)
new_state.delete_button.configure(text="DELETE", command=lambda : self.delete_state(new_state))
new_state.delete_button.grid(row=len(self.states), column=2)
new_state.accept_button.configure(text="ACCEPT", command=lambda : self.make_accepting(new_state))
new_state.accept_button.grid(row=len(self.states), column=3)
new_state.entry_button.configure(text="--->", command=lambda : self.make_entry(new_state))
new_state.entry_button.grid(row=len(self.states), column=4)
self.parser.add_state(new_state)
Geometry.add_state(self.canvas_window, new_state, self.states)
pass
示例14: draw
def draw(self, Canvas, line):
t_size = 8 / Canvas.Scale
point = self.pos
## Make the T shape with lines
downPoint = (point[0] , point[1]-t_size/2)
upPoint = (point[0], point[1]+t_size)
rightPoint = (point[0]+t_size, point[1]+t_size)
leftPoint = (point[0]-t_size, point[1]+t_size)
## rotate the T shape to always be normal to the edge
theta = Geom.angleFromXaxis(line)
lines = [leftPoint, rightPoint , upPoint, downPoint]
lines = Geom.rotatePointList(lines, theta, point)
Canvas.AddLine(
[lines[0], lines[1]],
LineWidth=4,
LineColor="BLUE"
)
Canvas.AddLine(
[lines[2], lines[3]],
LineWidth=4,
LineColor="BLUE"
)
示例15: addPolygon
def addPolygon(self, polygon, colour=None):
if not Visualiser.VISUALISER_ON:
return
if isinstance(polygon, geo.Polygon):
if colour == None:
visual.convex(pos=polygon.pts, color=geo.norm([0.1,0.1,0.1]), material=visual.materials.plastic)
else:
visual.convex(pos=convex.points, color=geo.norm(colour), opacity=0.5)