Exemplo n.º 1
0
	def __init__(self, midpoint, rot_matrix, r, k, d_eq):
		self.r = r
		self.k = k
		self.d_eq = d_eq
		
		self.L = (1/k * 8/3. * (2*r+1)**3 / ((r**2+4*r+1)*(r+1)) * 4*np.pi/3)**(1/3.) * d_eq * 0.5
		
		self.a_long = 1/(2*r+1) * self.L
		self.a_short = r * self.a_long
	
		self.H = np.sqrt(3)/2 * self.L
		self.h = (r+1)/(2*r+1) * self.H
		
		self.t = k*self.h
		
		self.circumcircle = np.sqrt((self.a_long/2.)**2 + (self.H/3.)**2 + (self.t/2.)**2)
		
		self.rot_matrix = rot_matrix
		self.rot_matrix_tr = np.ascontiguousarray(rot_matrix.transpose())
		angle, axis = GeometryTools.rotmatrix_to_axisangle(rot_matrix)
		self.rot_axis = axis
		self.rot_angle = angle
		self.euler_angles = GeometryTools.rotmatrix_to_euler(rot_matrix)
		
		self.basal_area = self.H*self.L/2. - 3*np.sqrt(3)/4 * self.a_short**2
		self.volume = self.basal_area*self.t
		
		# vertices in coordinates of the triangle
		if r > 0:
			self.vertices = np.array([[self.a_long/2, -self.H/3, -self.t/2], [self.a_long/2 + self.a_short/2, np.sqrt(3)/2*self.a_short - self.H/3, -self.t/2], [self.a_short/2, self.h - self.H/3, -self.t/2], [-self.a_short/2, self.h - self.H/3, -self.t/2], [-self.a_long/2 - self.a_short/2, np.sqrt(3)/2*self.a_short - self.H/3, -self.t/2], [-self.a_long/2, -self.H/3, -self.t/2]])
		else:
			self.vertices = np.array([[self.L/2, -self.H/3, -self.t/2], [0, 2*self.H/3, -self.t/2], [-self.L/2, -self.H/3, -self.t/2]])
		
		self.set_midpoint(midpoint)
Exemplo n.º 2
0
def compute_misorientation_net(t1,t2,symmetry=[]):
	"""
	Computes the misorientation between two truncated triangles t1 and t2.
	"""
	R1=t1.rot_matrix
	R2=t2.rot_matrix
	R2inv = np.linalg.inv(R2)
	net_rotation=np.dot(R1,R2inv)
	if len(symmetry)==0:	
		theta,axis = GT.rotmatrix_to_axisangle(net_rotation)
		return theta*180/math.pi
	else:
		angles=[]
		for i in xrange(len(symmetry)):
			for j in xrange(len(symmetry)):	
				theta,axis = GT.rotmatrix_to_axisangle( np.dot( np.dot(symmetry[i],R1),np.dot(R2inv,symmetry[j])))
				angles.append(theta*180/math.pi)
		
		return np.min(angles)