Sideway
output.to from Sideway
Draft for Information Only

Content

Transformation
 Types of Transformation
 Transformation Between Two Mobjects
  Examples:
   Transform, ReplacementTransform, TransformFromCopy, MoveToTarget
    Code
    Output
 Transformation of a Mobject
 Transformation of Animation Mobjects

Transformation

Transformation is one kind of animation in Manim. 

Types of Transformation

Types of Manim transformation are:
  • Transform
    • ClockwiseTransform
    • CounterclockwiseTransform
  • ReplacementTransform
  • TransformFromCopy
  • MoveToTarget
  • CyclicReplace
    • Swap
  • ApplyMethod
    • ApplyPointwiseFunction
      • ApplyPointwiseFunctionToCenter
      • ApplyMatrix
    • FadeToColor
    • ScaleInPlace
      • ShrinkToCenter
    • Restore
    • ApplyComplexFunction
    • specialized.MoveCar
  • ApplyFunction
  • TransformAnimations

Transformation Between Two Mobjects

Manim function to transform from one Mobject to another Mobject or vice versa. Both ClockwiseTransform and CounterclockwiseTransform transformations are used to specify argment of path_arc parameter.
  mobject target_mobject path_arc path_arc_axis path_func replace_mobject_with_target_in_scene
Transform   None 0 OUT None False
ReplacementTransform           True
TransformFromCopy target_mobject mobject        
ClockwiseTransform     -np.pi      
CounterclockwiseTransform     np.pi      
MoveToTarget   target_mobject        

Examples:

Transform, ReplacementTransform, TransformFromCopy, MoveToTarget

Code
# folder/file: tut/manim_animation_mobjectstransformation_001a.py

from manimlib.scene.scene import Scene
from manimlib.mobject.mobject import Group
from manimlib.mobject.geometry import Dot, Circle, Square
from manimlib.animation.creation import ShowCreation
from manimlib.animation.transform import Transform, ReplacementTransform, TransformFromCopy, MoveToTarget, ApplyMethod
from manimlib.mobject.svg.tex_mobject import TextMobject, TexMobject
from manimlib.animation.composition import AnimationGroup

class manim_animation_mobjectstransformation_001a(Scene): 
   def construct(self):
      rows,cols=(9,5)
      x0=[-4,*[2*i for i in range(cols-1)]]
      y0=[3.5,*[2.5-0.8*i for i in range(rows-1)]]
      txtx=["","loc 1","loc 2","m1 val","m2 val"]
      for i in range(cols): self.add(TextMobject(txtx[i]).move_to(([x0[i],y0[0],0])))
      xt=TextMobject(r"$\rightarrow$").move_to(([(x0[1]+x0[2])/2,y0[0],0]))
      txty=["","Transform","","ReplacementTransform","","TransformFromCopy","","MoveToTarget",""]
      for i in range(rows): self.add(TextMobject(txty[i]).move_to(([x0[0],y0[i],0])))
      self.add(xt)
      [[self.add(Dot().move_to(([x0[i],y0[j],0]))) for i in range(1,3)] for j in range(1,rows)] 
      d=Dot().set_width(0.0000001);a1=[d];a2=[d];a3=[d];a4=[d]
      for j in range(1,rows):
            a1.append(Circle().scale(0.2).move_to([x0[1],y0[j],0]))
            a2.append(Square().scale(0.2).move_to([x0[2],y0[j],0]))
            a3.append(a1[j].copy().move_to([x0[3],y0[j],0]).add_updater(lambda mob,obj=a1[j],x=x0[3],y=y0[j]:mob.become(obj.copy().move_to([x,y,0]))))
            a4.append(a2[j].copy().move_to([x0[4],y0[j],0]).add_updater(lambda mob,obj=a2[j],x=x0[4],y=y0[j]:mob.become(obj.copy().move_to([x,y,0]))))
      self.add(*a1[1::2],*a2[1::2])
      self.add(*a3,*a4)         
      a1[7].target=a2[7]
      a1[8].target=a2[8]
      for obj in a1[1:]:
         self.add(Square(stroke_width=2,color="#FFFF00").add_updater(lambda mob,obj=obj:mob.surround(obj,stretch=True,buff=0.2)))
      for obj in a2[1:]:
         self.add(Square(stroke_width=2,color="#DC75CD").add_updater(lambda mob,obj=obj:mob.surround(obj,stretch=True,buff=0.3)))
      self.wait(2)
      self.play(AnimationGroup(\
         Transform(a1[1],a2[1]),\
         Transform(a1[2],a2[2]),\
         ReplacementTransform(a1[3],a2[3]),\
         ReplacementTransform(a1[4],a2[4]),\
         TransformFromCopy(a1[5],a2[5]),\
         TransformFromCopy(a1[6],a2[6]),\
         MoveToTarget(a1[7]),\
         MoveToTarget(a1[8])\
            ),run_time=5)
      self.wait(3)
      Group(*a1).shift([0.3,0,0]).set_color("#11FF00")
      self.wait(3)
      self.play(ApplyMethod(Group(*a1).shift,([0.3,0,0])),run_time=3)
      self.wait(10)
Output
image

Transformation of a Mobject

Manim function to transform a Mobject.
  mobject target_mobject path_arc path_arc_axis path_func replace_mobject_with_target_in_scene
Transform   None 0 OUT None False
ApplyMethod            
ApplyPointwiseFunction            
ApplyPointwiseFunctionToCenter            
FadeToColor            
ScaleInPlace            
ShrinkToCenter            
Restore            
ApplyFunction            
ApplyMatrix            
ApplyComplexFunction            

Transformation of Animation Mobjects

  mobject target_mobject path_arc path_arc_axis path_func replace_mobject_with_target_in_scene
Transform   None 0 OUT None False
CyclicReplace *mobjects
(target[-1],*target[:-1])
(self.group) 90*DEGREES      
Swap *mobjects
(target[-1],*target[:-1])
(self.group) 90*DEGREES      
TransformAnimations start_anim
(start_anim.mobject)
end_anim
(end_anim.mobject)
       

©sideway

ID: 200500502 Last Updated: 5/17/2020 Revision: 1


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339new

Travel 7new

Reference 79

Computer

Hardware 251

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 431

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019