import pygame from kingdon import Algebra import math ERROR = 0.00001 alg = Algebra(2,1,0) locals().update(alg.blades) b = 2*e12 print(b) def motor(generator): bivector = generator.grade(2) sqr = (bivector*bivector).grade(0).e mag = bivector.norm().e generator = bivector.normalized() if mag < ERROR: #Zero Norm return 1+bivector elif sqr < 0: return math.cos(mag) + math.sin(mag)*generator else: return math.cosh(mag) + math.sinh(mag)*generator motor(1*e12) motor(1*e13) motor(1*e23) ''' # Initialize Pygame pygame.init() # Set up the screen WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Clifford and Pygame Example") # Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) # Initial point in GA (e.g., a vector representing a point) # We'll represent it as a multivector with a vector component initial_point_ga = 100 * e1 + 50 * e2 # Create a rotor for rotation (e.g., 45 degrees counter-clockwise) angle = math.pi / 4 # 45 degrees rotor = math.e**(angle * e12) # Game loop running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Clear the screen screen.fill(BLACK) # Apply the rotation to the point rotated_point_ga = rotor * initial_point_ga * ~rotor # Extract the vector components for Pygame display # We assume the point is a vector, so we access its e1 and e2 components x_coord = rotated_point_ga.value[e1.index] + WIDTH // 2 # Adjust for screen center y_coord = -rotated_point_ga.value[e2.index] + HEIGHT // 2 # Invert y for Pygame coordinates # Draw the point pygame.draw.circle(screen, RED, (int(x_coord), int(y_coord)), 5) # Update the display pygame.display.flip() # Quit Pygame pygame.quit() '''