Exemplo n.º 1
0
    def getSurfaceNormal(self, point):

        surfaceNormal = Vector()

        if self.center.x - self.radius <= point.x <= self.center.x + self.radius and self.center.z - self.radius <= point.z <= self.center.z + self.radius:

            epsilon = 0.00001

            if point.y > self.top.y - epsilon:
                return Vector(0.0, 1.0, 0.0)
            elif self.bottom.y - epsilon < point.y < self.bottom.y + epsilon:
                return Vector(0.0, -1.0, 0.0)

            v = Vector(self.center.x, point.y, self.center.z)
            surfaceNormal = point.sub(v)

        return surfaceNormal.normalize()
Exemplo n.º 2
0
    def getSurfaceNormal(self,point):

        surfaceNormal = Vector()

        epsilon = 0.00001

        if point.y > self.center.y - epsilon:
            surfaceNormal.y = 1
            return Vector(0.0, 1.0, 0.0)
        elif self.bottom.y - epsilon < point.y < self.bottom.y + epsilon:
            surfaceNormal.y = -1
            return Vector(0.0, -1.0, 0.0)

        x = point.x - self.center.x
        z = point.z - self.center.z

        r = math.sqrt(math.pow(x, 2) + math.pow(z, 2))
        surfaceNormal = Vector(x, r * (self.radius / self.height), z)
        return surfaceNormal.normalize()