Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
import pygame
import numpy as np
from pygame.locals import QUIT, KEYDOWN, KEYUP
from OpenGL.GL import *
from OpenGL.GLU import *
import sys
class Engine:
def __init__(self, w, h,
fov=np.pi/4, near=0.1, far=100.0,
import pygame
import numpy as np
from pygame.locals import QUIT, KEYDOWN, KEYUP
from OpenGL.GL import *
from OpenGL.GLU import *
class Engine:
def __init__(self, w, h,
fov=np.pi/4, near=0.1, far=100.0,
init_pos=None, init_yaw=-90.0, init_pitch=0.0):
import pygame
import numpy as np
from pygame.locals import QUIT, KEYDOWN, KEYUP
from OpenGL.GL import *
from OpenGL.GLU import *
class Engine:
def __init__(self, w, h,
fov=np.pi/4, near=0.1, far=100.0,
init_pos=None, init_yaw=-90.0, init_pitch=0.0):
import numpy as np
import time
def rotation_matrix(axis, theta):
axis = axis / np.linalg.norm(axis)
a = np.cos(theta / 2.0)
b, c, d = -axis*np.sin(theta / 2.0)
aa, bb, cc, dd = a*a, b*b, c*c, d*d
bc, ad, ac, ab, bd, cd = b*c, a*d, a*c, a*b, b*d, c*d
return np.array([[aa+bb-cc-dd, 2*(bc+ad), 2*(bd-ac), 0],
import numpy as np
import time
from math import cos, sin, acos, sqrt
# --- Quaternion utility functions for rotations ---
def quat_from_axis_angle(axis, angle_rad):
axis = axis / np.linalg.norm(axis)
s = sin(angle_rad / 2)
return np.array([cos(angle_rad/2), axis[0]*s, axis[1]*s, axis[2]*s])
import pygame as g, sys, math
import numpy as n
# Init
g.init()
s = g.display.set_mode((800, 600))
w, h = s.get_size()
g.display.set_caption("3D LOS with NumPy Optimization")
c = g.time.Clock()
g.event.set_grab(True)
import pygame
import numpy as np
import sys
import math
# Initialize Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("3D Line of Sight with Mouse Look")
clock = pygame.time.Clock()
import pygame
import numpy as np
import sys
import math
# Initialize Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("3D Line of Sight with Mouse Look")
clock = pygame.time.Clock()
import pygame
import numpy as np
import sys
import math
# Initialize Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("3D Line of Sight with Mouse Look")
clock = pygame.time.Clock()
import pygame
import numpy as np
import sys
import math
# Initialize Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("3D Line of Sight with Mouse Look")
clock = pygame.time.Clock()