def calc_pixelpoint(x, y): dx = float(x)/meanp - 0.5 dy = float(y)/meanp - 0.5 xv = poly.vector(poly.point([0, 0, 0]), poly.point([1, 0, 0])) yv = poly.vector(poly.point([0, 0, 0]), poly.point([0, -1, 0])) pixel = camerap.sum(camerav.mult(zoom)).sum(xv.mult(dx)).sum(yv.mult(dy)) return pixel
#!/usr/bin/python import poly import sys import pickle if (len(sys.argv) < 4): quit() file = sys.argv[1] x_pix = int(sys.argv[2]) y_pix = int(sys.argv[3]) meanp = (y_pix * x_pix)**0.5 camerap = poly.point([0.0, 0.0, -10.0]) camerav = poly.vector(poly.point([0, 0, 0]), poly.point([0.0, 0.0, 1.0])) zoom = 1.0 light1 = (poly.point([0.0, 10, -4]), 200) lights = [light1] mesh = poly.mesh() mesh.load_raw(file) def calc_pixelpoint(x, y): dx = float(x)/meanp - 0.5 dy = float(y)/meanp - 0.5 xv = poly.vector(poly.point([0, 0, 0]), poly.point([1, 0, 0])) yv = poly.vector(poly.point([0, 0, 0]), poly.point([0, -1, 0])) pixel = camerap.sum(camerav.mult(zoom)).sum(xv.mult(dx)).sum(yv.mult(dy))
import poly m = poly.mesh() m.load_raw("ball4.raw") r1 = poly.ray(p1 = poly.point([1, 20, 1]), p2 = poly.point([1, 19, 1])) print(m.test_collision(r1)) r1.debug_print()