Example #1
0
    def to_spherical(self):
        r = self.get_magnitude()
        theta = math.atan(self.y / nonzero(self.x))
        phi = math.atan(math.sqrt(self.x**2 + self.y**2) / nonzero(self.z))

        if self.y < 0:
            phi += math.pi

        if self.x < 0:
            theta += math.pi

        return Spherical(r, theta, phi)
Example #2
0
    def get_overlaid_colours(self, colours, leds, time_since_start,
                             fixture_name):
        if fixture_name not in self.global_z.keys():
            self.global_z[fixture_name] = np.array(
                list(led.coord.get("global", "cartesian").z for led in leds))

        self.intensity = 1.0 / nonzero((time_since_start * 0.5)**2)

        effective_intensity = min(1.0, self.intensity)

        fade_level = np.sin(self.global_z[fixture_name] * 2 -
                            time_since_start * 1.0 + math.pi * 1.5) + 1.0
        np.clip(1.0, 0.0, fade_level)

        warp_core_level = np.sin(self.global_z[fixture_name] * 25 -
                                 time_since_start * 8) / 1.5 + 0.5
        np.clip(1.0, 0.0, warp_core_level)

        fade_level *= effective_intensity

        warp_core_level *= fade_level * 1.4

        fade_level = fade_level[:len(colours)]
        warp_core_level = warp_core_level[:len(colours)]

        fade_level = fade_level[:, np.newaxis]
        warp_core_level = warp_core_level[:, np.newaxis]

        return colours * (1 - fade_level) + (
            colours + 16 * effective_intensity) * fade_level * warp_core_level
Example #3
0
    def to_cylindrical(self):
        r = math.sqrt(self.x**2 + self.y**2)
        theta = math.atan(self.y / nonzero(self.x))
        z = self.z

        if self.x < 0:
            theta += math.pi

        return Cylindrical(r, theta, z)
Example #4
0
    def get_overlaid_colours(self, colours, leds, time_since_start,
                             fixture_name):
        factor = min(
            2.0, 1.0 / nonzero((time_since_start + 0.25) * self.decay_factor))

        return colours * max(factor, 1)