def calc_vector_dimensions(self): relative_translation = self.shortest_vector_relative_to(self.parent) if relative_translation is None: self.length = 0 else: self.length = numpy.sqrt( numpy.dot(relative_translation, relative_translation)) if self.length > 0: t = self.children[0].translation_relative_to(self.parent) c = relative_translation[2] / self.length if c >= 1.0: self.orientation = Translation(t) elif c <= -1.0: alpha = numpy.pi axis = numpy.array([1.0, 0.0, 0.0]) self.orientation = Complete.from_properties( alpha, axis, False, t) else: x, y = relative_translation[0], relative_translation[1] if abs(x) < abs(y): signy = {True: 1, False: -1}[y >= 0] a = -signy b = signy * x / y else: signx = {True: 1, False: -1}[x >= 0] a = -signx * y / x b = signx alpha = numpy.arccos(c) axis = numpy.array([a, b, 0.0]) self.orientation = Complete.from_properties( alpha, axis, False, t)
def calc_vector_dimensions(self): relative_translation = self.shortest_vector_relative_to(self.parent) if relative_translation is None: self.length = 0 else: self.length = numpy.sqrt(numpy.dot(relative_translation, relative_translation)) if self.length > 0: t = self.children[0].translation_relative_to(self.parent) c = relative_translation[2] / self.length if c >= 1.0: self.orientation = Translation(t) elif c <= -1.0: alpha = numpy.pi axis = numpy.array([1.0, 0.0, 0.0]) self.orientation = Complete.from_properties(alpha, axis, False, t) else: x, y = relative_translation[0], relative_translation[1] if abs(x) < abs(y): signy = {True: 1, False: -1}[y >= 0] a = -signy b = signy * x / y else: signx = {True: 1, False: -1}[x >= 0] a = -signx * y / x b = signx alpha = numpy.arccos(c) axis = numpy.array([a, b, 0.0]) self.orientation = Complete.from_properties(alpha, axis, False, t)
def convert_to_value(self, representation): properties = (ComposedInTable.convert_to_value(self.fields[0], representation[0]) + (ComposedArray.convert_to_value(self.fields[1], representation[1]), )) return MathComplete.from_properties(*properties)
def convert_to_value(self, representation): properties = ( ComposedInTable.convert_to_value(self.fields[0], representation[0]) + (ComposedArray.convert_to_value(self.fields[1], representation[1]),) ) return MathComplete.from_properties(*properties)