def rotatePattern(self, axis, angle): middlePoint = GeoMath.getCenterEdge( [self.points[0], self.points[len(self.points) - 1]]) middlePoint.append(1) trans = GeoMath.Matrix(4, 4) trans.matrix4Trans(middlePoint) transIn = GeoMath.Matrix(4, 4) transIn.copy(trans) transIn.matrix4Inverse() for num in range(len(self.points)): pointRot = list(self.points[num]) pointRot.append(1) pointRot = transIn.mulPoint4ToMatrix4(pointRot) if (axis == [1, 0, 0]): Rx = GeoMath.Matrix(4, 4) Rx.singleRotx(angle) pointRot = Rx.mulPoint4ToMatrix4(pointRot) elif (axis == [0, 1, 0]): Ry = GeoMath.Matrix(4, 4) Ry.singleRoty(angle) pointRot = Ry.mulPoint4ToMatrix4(pointRot) else: Rz = GeoMath.Matrix(4, 4) Rz.singleRotz(angle) pointRot = Rz.mulPoint4ToMatrix4(pointRot) pointRot = trans.mulPoint4ToMatrix4(pointRot) self.points[num] = pointRot # Rotate normal logging.debug('Normal not rotated:' + str(self.normal)) to_rotate_normal = self.normal to_rotate_normal.append(0) if (axis == [1, 0, 0]): Rx = GeoMath.Matrix(4, 4) Rx.singleRotx(angle) normalRot = Rx.mulPoint4ToMatrix4(to_rotate_normal) elif (axis == [0, 1, 0]): Ry = GeoMath.Matrix(4, 4) Ry.singleRoty(angle) normalRot = Ry.mulPoint4ToMatrix4(to_rotate_normal) else: Rz = GeoMath.Matrix(4, 4) Rz.singleRotz(angle) normalRot = Rz.mulPoint4ToMatrix4(to_rotate_normal) normalRot.pop() logging.debug('Normal rotated: ' + str(normalRot)) self.normal = normalRot
def rotatePattern(self, axis, angle): middlePoint = GeoMath.getCenterEdge([self.points[0], self.points[len(self.points) - 1]]) middlePoint.append(1) trans = GeoMath.Matrix(4, 4) trans.matrix4Trans(middlePoint) transIn = GeoMath.Matrix(4, 4) transIn.copy(trans) transIn.matrix4Inverse() for num in range(len(self.points)): pointRot = list(self.points[num]) pointRot.append(1) pointRot = transIn.mulPoint4ToMatrix4(pointRot) if(axis == [1, 0, 0]): Rx = GeoMath.Matrix(4, 4) Rx.singleRotx(angle) pointRot = Rx.mulPoint4ToMatrix4(pointRot) elif(axis == [0, 1, 0]): Ry = GeoMath.Matrix(4, 4) Ry.singleRoty(angle) pointRot = Ry.mulPoint4ToMatrix4(pointRot) else: Rz = GeoMath.Matrix(4, 4) Rz.singleRotz(angle) pointRot = Rz.mulPoint4ToMatrix4(pointRot) pointRot = trans.mulPoint4ToMatrix4(pointRot) self.points[num] = pointRot # Rotate normal logging.debug('Normal not rotated:' + str(self.normal)) to_rotate_normal = self.normal to_rotate_normal.append(0) if(axis == [1, 0, 0]): Rx = GeoMath.Matrix(4, 4) Rx.singleRotx(angle) normalRot = Rx.mulPoint4ToMatrix4(to_rotate_normal) elif(axis == [0, 1, 0]): Ry = GeoMath.Matrix(4, 4) Ry.singleRoty(angle) normalRot = Ry.mulPoint4ToMatrix4(to_rotate_normal) else: Rz = GeoMath.Matrix(4, 4) Rz.singleRotz(angle) normalRot = Rz.mulPoint4ToMatrix4(to_rotate_normal) normalRot.pop() logging.debug('Normal rotated: ' + str(normalRot)) self.normal = normalRot