A commit.

This commit is contained in:
bʰedoh₂ swé 2024-04-03 18:06:28 +05:00
parent 0d6d8c3339
commit a0a33254e3
2 changed files with 15 additions and 13 deletions

10
gyro.py
View File

@ -1,7 +1,7 @@
from numpy import complex128
from numpy import complex256
def ZeroCheck(cN):
if cN == complex128(complex(0,0)):
return complex128(complex(1,0))
if cN == complex256(complex(0,0)):
return complex256(complex(1,0))
else:
return cN
@ -31,8 +31,8 @@ def Poincare2Klein(cN):
class GyroVector:
def __init__(self, cPos, cRot):
self.cPos = complex128(cPos)
self.cRot = complex128(cRot)
self.cPos = complex256(cPos)
self.cRot = complex256(cRot)
self.normalize()
def __add__(gA, gB):

18
main.py
View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from numpy import complex128
from numpy import complex256
from time import time_ns, sleep
from cmath import exp, pi
import pygame
@ -11,7 +11,7 @@ from lines import *
def deg2rad(rA): return rA/180*PI
I = complex128(complex(0,1))
I = complex256(complex(0,1))
WHITE = (255,255,255)
BLACK = (0,0,0)
OFFSET = 0.015625
@ -37,10 +37,10 @@ class DrawnSegment:
self.color = color
level = [
Segment(False,.6,I*.6,(255,0,0)),
Segment(False,.6,-I*.6,(0,255,0)),
Segment(False,-.6,-I*.6,(0,0,255)),
Segment(False,-.6,I*.6,(255,255,0))
Segment(True,.6,I*.6,(255,0,0)),
Segment(True,.6,-I*.6,(0,255,0)),
Segment(True,-.6,-I*.6,(0,0,255)),
Segment(True,-.6,I*.6,(255,255,0))
]
def draw(level,gPlayer,fov,res):
@ -54,10 +54,12 @@ def draw(level,gPlayer,fov,res):
tA = Poincare2Klein(MobiusAdd(j.pointA,-gPlayer.cPos))
tB = Poincare2Klein(MobiusAdd(j.pointB,-gPlayer.cPos))
try: # This function faults from time to time
cInt = cLineIntersection(tA,tB,complex128(0),rot)
cInt = cLineIntersection(tA,tB,complex256(0),rot)
except ZeroDivisionError:
continue
rDist = cDist(0,cInt) * irot.real
rDist = cDist(0,cInt)
if not (j.isFinite and cBetween(tA,tB,cInt)):
continue
if cDot(cInt,rot) > 0:
continue
if (1 - m.height) > rDist: