Exemplo n.º 1
0
 def __init__(self, origin, direction):
     """initializies the ray
         @origin is the point where the ray starts
         @direction is the vector in which the ray points
     """
     self.origin = origin  #Punkt
     self.direction = hf.normalize(direction)  #Vektor
Exemplo n.º 2
0
 def __init__(self, point, normal, material=None):
     """initializes the plane
         @point is where you look for the normal
         @normal is the normal of the plane, that shows you the inclination
     """
     self.point = point
     self.normal = hf.normalize(normal)
     self.material = material  #if material else mat()
Exemplo n.º 3
0
    def colorAt(self, lightRay, lightColor, normal, direction, intersection):
        """gives the color at the parameters
        """
        if self.color2 is None:
            lightRay = hf.normalize(lightRay)
            lr = hf.cVector(lightRay[0], -lightRay[2], lightRay[1])

            norm = (self.reflection + 2) / (2 * np.pi)
            Ca = self.color * self.ka
            Cd = lightColor * self.kd * np.dot(lightRay, normal)
            Cs = lightColor * self.ks * norm * (np.dot(lr, -direction)**
                                                self.reflection)
            Co = Ca + Cd + Cs

            return Co
        else:
            v = intersection * (1.0 / self.checkSize)
            if (int(abs(v[0]) + 0.5) + int(abs(v[1]) + 0.5) +
                    int(abs(v[2]) + 0.5)) % 2:
                return self.color
            return self.color2
Exemplo n.º 4
0
BACKGROUND_COLOR = hf.cVector(20, 20, 20)

ASPRATIO = WIDTH / HEIGHT

lichtquelle = lq(hf.cVector(5, 5, -2), hf.cVector(200, 200, 200))
shadowFactor = 0.5  #auspraegung des Schattens
reflectFactor = 0.5

e = hf.cVector(0, 0, 0)  #camera position
c = hf.cVector(0, 0, 50)  #camera center
up = hf.cVector(0, -1, 0)  #up vector
FOV = 45  #Field of View

#extern camera parameters
f = hf.normalize((np.subtract(c, e)))  #z coordinate
s = hf.normalize(np.cross(f, up))  #x coordiante
u = np.cross(s, f)  #y coordinate

#intern camera parameters
alpha = np.deg2rad(FOV) / 2.0
viewheight = 2 * np.tan(alpha)  #heigth of viewport
viewWidth = ASPRATIO * viewheight  #width of viewport

pixelWidth = viewWidth / WIDTH  #width of a pixel
pixelHeigth = viewheight / HEIGHT  #height of a pixel
"""init scene"""
objectList = []
if MODE == 6:
    objectList.append(
        Sphere(hf.cVector(0, 5, 20), 2,
Exemplo n.º 5
0
 def normalAt(self):
     return hf.normalize(np.cross(self.u, self.v))
Exemplo n.º 6
0
 def normalAt(self, p):
     """return the normal of the sphere in point p"""
     return hf.normalize((np.subtract(p, self.center)))