got horizontal stripes working, trying to add a curve to them

This commit is contained in:
Sakimori 2021-06-28 03:51:02 -04:00
parent fb222b6dea
commit 6b95683fcd
2 changed files with 26 additions and 6 deletions

View file

@ -97,7 +97,7 @@ if __name__=="__main__":
running = True running = True
display = False display = False
thisEarth = deepcopy(Planet.Earth) thisEarth = deepcopy(Planet.Earth)
sat = OrbitingBody(Point(config()["earthRadius"] * 1.1, 0, 0), Point(0,1000,-8500), "BoSLOO", 3, thisEarth) sat = OrbitingBody(Point(config()["earthRadius"] * 1.1, 0, 0), Point(2000,6000,-2500), "BoSLOO", 3, thisEarth)
orbitlines = [] orbitlines = []
renderObjects = [thisEarth, sat, orbitlines] renderObjects = [thisEarth, sat, orbitlines]
imageThread = threading.Thread() imageThread = threading.Thread()
@ -110,7 +110,7 @@ if __name__=="__main__":
elif event.type == pygame.MOUSEBUTTONDOWN: elif event.type == pygame.MOUSEBUTTONDOWN:
if not display: if not display:
display = True display = True
camera = Camera(window, Point(0, 0, 8 * config()["earthRadius"]), thisEarth, renderObjects) camera = Camera(window, Point(0, 0, 5 * config()["earthRadius"]), thisEarth, renderObjects)
pygame.draw.circle(window, (255,255,255), pygame.mouse.get_pos(), 100) pygame.draw.circle(window, (255,255,255), pygame.mouse.get_pos(), 100)
camera.renderFrame() camera.renderFrame()
pygame.display.flip() pygame.display.flip()

View file

@ -1,4 +1,4 @@
import numpy, pygame import numpy, pygame, math
class Point: class Point:
"""Numpy 3-vec""" """Numpy 3-vec"""
@ -125,19 +125,39 @@ class Camera:
#pygame uses 0,0 as the top left corner #pygame uses 0,0 as the top left corner
satDistance = -1 satDistance = -1
#DEBUG
minlat = 1
for column in range(0, winWidth): for column in range(0, winWidth):
for row in range(0, winHeight): for row in range(0, winHeight):
#get line in world going through this pixel #get line in world going through this pixel
worldLine = Line(self.location, Point.add(screenPlaneOrigin, Point(column, row, 0))) worldLine = Line(self.location, Point.add(screenPlaneOrigin, Point(column, row, 0)))
#compare distance from center of planet to radius of planet to determine intersection #compare distance from center of planet to radius of planet to determine intersection
if self.target.location.distanceFromLine(worldLine) < self.target.radius:
screenSurface.set_at((column, row), (100,255,100))
dist = frozenSat.distanceFromLine(worldLine) dist = frozenSat.distanceFromLine(worldLine)
if satDistance < 0 or dist < satDistance: if satDistance < 0 or dist < satDistance:
satDistance = dist satDistance = dist
satPixel = (column, row) satPixel = (column, row)
if self.target.location.distanceFromLine(worldLine) < self.target.radius:
epsilon = 0.1
yPrime = (row + screenPlaneOrigin.vector[1]) * (self.location.vector[2] / winDistance)
xPrime = min([abs((column + screenPlaneOrigin.vector[0]) * (self.location.vector[2] / winDistance)), self.target.radius])
try:
lat = math.modf((math.acos(yPrime / self.target.radius) / (3.141592/12.0)))[0] * math.sin(math.acos(xPrime / self.target.radius))
except:
screenSurface.set_at((column, row), (20,20,20))
continue
if lat < minlat:
minlat = lat
if -epsilon < lat < epsilon:
screenSurface.set_at((column, row), (200,200,200))
else:
screenSurface.set_at((column, row), (20,20,20))
if screenSurface.get_at(satPixel) == (0,0,0): if screenSurface.get_at(satPixel) == (0,0,0):
circleBorder = 0 circleBorder = 0
else: else: