def schnittgerade(self, plane1: Plane, plane2: Plane): """Calculates and Returns the schnittgerade of two Planes. Returns a Line instance.""" pla1 = plane1.convertToHessianNormalForm() pla2 = plane2.convertToHessianNormalForm() normvec1 = pla1.normVec normvec2 = pla2.normVec posnum1 = pla1.posVec.scalarProduct(normvec1) posnum2 = pla2.posVec.scalarProduct(normvec2) schnittgerade = not Solvers.checkLinearAbhaengig( normvec1, normvec2) # Testing if the Planes are not Parallel if schnittgerade: dirVec = normvec1.vectorProduct(normvec2) posVecScalar1 = ((posnum1 * normvec2.square()) - (posnum2 * normvec1.scalarProduct(normvec2))) / ( (normvec1.square() * normvec2.square()) - normvec1.scalarProduct(normvec2)**2) posVecScalar2 = ((posnum2 * normvec1.square()) - (posnum1 * normvec1.scalarProduct(normvec2))) / ( (normvec1.square() * normvec2.square()) - normvec1.scalarProduct(normvec2)**2) normvec1 = normvec1.scalarMultiplication(posVecScalar1) normvec2 = normvec2.scalarMultiplication(posVecScalar2) posVec = normvec1.add(normvec2) schnittgerade = Line(posVec, dirVec, name=("Schnittgerade von " + pla1.name + " und " + pla2.name)) return schnittgerade
def main(): pygame.init() screen = pygame.display.set_mode((640,480)) pygame.display.set_caption("Animated Line") line = Line(screen) clock = pygame.time.Clock() while 1: clock.tick(30) screen.fill((50, 50, 100)) line.update() line.draw() pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: pygame.quit() return elif event.type == KEYDOWN and event.key == K_ESCAPE: pygame.quit() return
Vec2 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Ergebnis: " + str(Vec1.scalarProduct(Vec2))) elif UserInput == "VecMultVecCro": Vec1 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) Vec2 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Ergebnis: " + str(Vec1.vectorProduct(Vec2))) elif UserInput == "NewPoi": PoiList.append(Point(input("x = "),input("y = "),input("z = "),input("Name = "))) print(str(PoiList[-1])) elif UserInput == "NewLin": print("Position Vector: ") Vec1 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Direction Vector: ") Vec2 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) name = input("Name: ") LinList.append(Line(Vec1, Vec2, name, (0, 0, 0))) print(str(LinList[-1])) elif UserInput == "NewPla": print("Position Vector: ") Vec1 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Direction Vector One: ") Vec2 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Direction Vector Two: ") Vec3 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) name = input("Name: ") PlaList.append(Plane.parameterForm(Vec1, Vec2, Vec3, name, (0, 0, 0))) print(str(PlaList[-1])) elif UserInput == "ConvertPlaToHess": print("Position Vector: ") Vec1 = Vector3D(input("x = "),input("y = "),input("z = "),input("Name = ")) print("Direction Vector One: ")