How to use the manimlib.utils.space_ops.rotate_vector function in manimlib

To help you get started, we’ve selected a few manimlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3b1b / manim / manimlib / mobject / geometry.py View on Github external
def get_arc_center(self):
        """
        Looks at the normals to the first two
        anchors, and finds their intersection points
        """
        # First two anchors and handles
        a1, h1, h2, a2 = self.points[:4]
        # Tangent vectors
        t1 = h1 - a1
        t2 = h2 - a2
        # Normals
        n1 = rotate_vector(t1, TAU / 4)
        n2 = rotate_vector(t2, TAU / 4)
        try:
            return line_intersection(
                line1=(a1, a1 + n1),
                line2=(a2, a2 + n2),
            )
        except Exception:
            warnings.warn("Can't find Arc center, using ORIGIN instead")
            return np.array(ORIGIN)
github 3b1b / manim / manimlib / once_useful_constructs / light.py View on Github external
def viewing_rays(self, screen):

        lower_angle, upper_angle = self.viewing_angles(screen)
        projected_RIGHT = self.project(
            RIGHT) / get_norm(self.project(RIGHT))
        lower_ray = rotate_vector(
            projected_RIGHT, lower_angle, axis=self.projection_direction())
        upper_ray = rotate_vector(
            projected_RIGHT, upper_angle, axis=self.projection_direction())

        return lower_ray, upper_ray
github 3b1b / manim / manimlib / once_useful_constructs / light.py View on Github external
def viewing_rays(self, screen):

        lower_angle, upper_angle = self.viewing_angles(screen)
        projected_RIGHT = self.project(
            RIGHT) / get_norm(self.project(RIGHT))
        lower_ray = rotate_vector(
            projected_RIGHT, lower_angle, axis=self.projection_direction())
        upper_ray = rotate_vector(
            projected_RIGHT, upper_angle, axis=self.projection_direction())

        return lower_ray, upper_ray
github 3b1b / manim / manimlib / mobject / geometry.py View on Github external
def get_arc_center(self):
        """
        Looks at the normals to the first two
        anchors, and finds their intersection points
        """
        # First two anchors and handles
        a1, h1, h2, a2 = self.points[:4]
        # Tangent vectors
        t1 = h1 - a1
        t2 = h2 - a2
        # Normals
        n1 = rotate_vector(t1, TAU / 4)
        n2 = rotate_vector(t2, TAU / 4)
        try:
            return line_intersection(
                line1=(a1, a1 + n1),
                line2=(a2, a2 + n2),
            )
        except Exception:
            warnings.warn("Can't find Arc center, using ORIGIN instead")
            return np.array(ORIGIN)
github 3b1b / manim / manimlib / mobject / types / vectorized_mobject.py View on Github external
elif len(points) == 2:
            handle2, new_anchor = points
        else:
            name = sys._getframe(0).f_code.co_name
            raise Exception("Only call {} with 1 or 2 points".format(name))

        if self.has_new_path_started():
            self.add_line_to(new_anchor)
        else:
            self.throw_error_if_no_points()
            last_h2, last_a2 = self.points[-2:]
            last_tangent = (last_a2 - last_h2)
            handle1 = last_a2 + last_tangent
            if handle2 is None:
                to_anchor_vect = new_anchor - last_a2
                new_tangent = rotate_vector(
                    last_tangent, PI, axis=to_anchor_vect
                )
                handle2 = new_anchor - new_tangent
            self.append_points([
                last_a2, handle1, handle2, new_anchor
            ])
        return self
github Solara570 / demo-solara / short / apollonian_gasket.py View on Github external
def calc_centers_by_radii(r1, r2, r3, init_angle = 0):
    if init_angle is None:
        init_angle = TAU * np.random.random_sample()
    r12 = r1 + r2
    r23 = r2 + r3
    r13 = r1 + r3
    cos_theta = (r12**2 + r13**2 - r23**2) / (2*r12*r13)
    theta = math.acos(cos_theta)
    p1 = ORIGIN
    p2 = p1 + rotate_vector(RIGHT, init_angle) * r12
    p3 = p1 + rotate_vector(RIGHT * r13, init_angle + theta)
    return p1, p2, p3
github 3b1b / manim / manimlib / mobject / geometry.py View on Github external
def get_arc_center(self):
        """
        Looks at the normals to the first two
        anchors, and finds their intersection points
        """
        # First two anchors and handles
        a1, h1, h2, a2 = self.points[:4]
        # Tangent vectors
        t1 = h1 - a1
        t2 = h2 - a2
        # Normals
        n1 = rotate_vector(t1, TAU / 4)
        n2 = rotate_vector(t2, TAU / 4)
        try:
            return line_intersection(
                line1=(a1, a1 + n1),
                line2=(a2, a2 + n2),
            )
        except Exception:
            warnings.warn("Can't find Arc center, using ORIGIN instead")
            return np.array(ORIGIN)
github Solara570 / demo-solara / short / apollonian_gasket.py View on Github external
def calc_centers_by_radii(r1, r2, r3, init_angle = 0):
    if init_angle is None:
        init_angle = TAU * np.random.random_sample()
    r12 = r1 + r2
    r23 = r2 + r3
    r13 = r1 + r3
    cos_theta = (r12**2 + r13**2 - r23**2) / (2*r12*r13)
    theta = math.acos(cos_theta)
    p1 = ORIGIN
    p2 = p1 + rotate_vector(RIGHT, init_angle) * r12
    p3 = p1 + rotate_vector(RIGHT * r13, init_angle + theta)
    return p1, p2, p3
github 3b1b / manim / manimlib / mobject / geometry.py View on Github external
def __init__(self, n=6, **kwargs):
        digest_config(self, kwargs, locals())
        if self.start_angle is None:
            if n % 2 == 0:
                self.start_angle = 0
            else:
                self.start_angle = 90 * DEGREES
        start_vect = rotate_vector(RIGHT, self.start_angle)
        vertices = compass_directions(n, start_vect)
        Polygon.__init__(self, *vertices, **kwargs)