def __init__(self, ADDone, ADDtwo): super(CSGadd, self).__init__() self.ADDone = ADDone self.ADDtwo = ADDtwo self.reference = 'CSGadd' self.transform = tf.identity_matrix()
def __init__(self, INTone, INTtwo): super(CSGint, self).__init__() self.INTone = INTone self.INTtwo = INTtwo self.reference = 'CSGint' self.transform = tf.identity_matrix()
def __init__(self, SUBplus, SUBminus): """ Definition {CSGsub} := {SUBplus}/{SUBminus} """ super(CSGsub, self).__init__() self.SUBplus = SUBplus self.SUBminus = SUBminus self.reference = 'CSGsub' self.transform = tf.identity_matrix()
def rotation_matrix_from_vector_alignment(before, after): """ :param before: vector before rotation :param after: vector after rotation :return: rotation matrix """ """ >>> # General input/output test >>> V1 = norm(np.random.random(3)) >>> V2 = norm([1, 1, 1]) >>> R = rotation_matrix_from_vector_alignment(V1, V2) >>> V3 = transform_direction(V1, R) >>> cmp_points(V2, V3) True >>> # Catch the special case in which we cannot take the cross product >>> V1 = [0, 0, 1] >>> V2 = [0, 0, 1] >>> R = rotation_matrix_from_vector_alignment(V1, V2) >>> V3 = transform_direction(V1, R) >>> cmp_points(V2, V3) True >>> # Catch the special case in which we cannot take the cross product >>> V1 = [0, 0, 1] >>> V2 = [0, 0, -1] >>> R = rotation_matrix_from_vector_alignment(V1, V2) >>> V3 = transform_direction(V1, R) >>> cmp_points(V2, V3) True """ # The angle between the vectors must not be 0 or 180 (i.e. so we can take a cross product) # import pdb; pdb.set_trace() the_dot = np.dot(before, after) if cmp_floats(the_dot, 1.): # Vectors are parallel return tf.identity_matrix() if cmp_floats(the_dot, -1.): # Vectors are anti-parallel # print "Vectors are anti-parallel this might crash." return tf.identity_matrix() * -1. rotation_axis = np.cross(before, after) # get the axis of rotation rotation_angle = np.arccos(np.dot(before, after)) # get the rotation angle return rotation_matrix(rotation_angle, rotation_axis)
def __init__(self, transform=None): """ Transform is a 4x4 transformation matrix that rotates and translates the plane into the global frame (a plane in the xy plane point with normal along (+ve) z). """ super(Plane, self).__init__() self.transform = transform if self.transform is None: self.transform = tf.identity_matrix()
def transform_direction(direction, transform): try: rotation_angle, rotation_axis, point = tf.rotation_from_matrix(transform) except ValueError: if tf.is_same_transform(tf.identity_matrix() * -1, transform): # The ray direction needs to be reversed return np.array(direction) * -1. rotation_transform = tf.rotation_matrix(rotation_angle, rotation_axis) return np.array(np.dot(rotation_transform, np.matrix(np.concatenate((direction, [1.]))).transpose()).transpose()[0,0:3]).squeeze()
def __init__(self, add_one, add_two): super(CSGadd, self).__init__() self.ADDone = add_one self.ADDtwo = add_two self.reference = 'CSGadd' self.transform = tf.identity_matrix()
def __init__(self, radius=1, length=1): super(Cylinder, self).__init__() self.radius = radius self.length = length self.transform = tf.identity_matrix()
def __init__(self, origin=(0, 0, 0), extent=(1, 1, 1)): super(Box, self).__init__() self.origin = np.array(origin) self.extent = np.array(extent) self.points = [origin, extent] self.transform = tf.identity_matrix()