I. Mathematics
Linear equation: Y = f (x); AX + by + c = 0;
Oblique truncation: Y = kx + B;
Curve oblique formula: y-y1 = K (x-x1 );
Slope formula: K = y-y1/(x-x1 );
Intercept: X/A + Y/B = 1;
Linear Parameter equation:
Its formula is y-y0 = Tg (A) (x-x0), which is transformed into a parametric equation.
Step 1: (y-y0)/sin (A) = (x-x0)/cos ();
Step 2: Set t on both sides of the Parameter
(Y-y0)/sin (A) = T;
(X-x0)/cos (A) = T;
Step 3: Convert
X = x0 + T * Cos ();
Y = y0 + T * sin ();
Ii. linear equation creation
Step 1: Create a ball and link the ball class.
Step 2: Copy n balls in our scenario and initialize the coordinates of the ball.
Suppose we set it to 20
For (var I: Int = 0; I <20; I ++) <br/> {<br/> // var G: Number = angle * I * Math. PI/180; <br/> var ball: ball = new ball (); <br/> addchild (ball); <br/> list. push (ball); <br/> ball. X = 50; <br/> ball. y = 60; <br/> trace (list [I] + I); </P> <p>}
List is an array. array is used to manage the ball instances we have created. Specify the initialization locations X and Y
Then the distribution ball is a straight line: This is the distribution starting from the second ball, that is to say, the list [1] instance of the array is used to distribute its position. Its position is based on the previous instance, each ball and the first ball have a difference of 20 X axis and 15 y axis.
For (var j: Int = 0; j <= 18; j ++) <br/>{< br/> list [J + 1]. X = list [J]. X + 20; <br/> list [J + 1]. y = list [J]. Y + 15; <br/> // trace (list [J-1]. x); <br/>}
Step 3: generate an animation
In order to make the replicated object produce results, we add the rotation attribute to change the angular velocity.
Addeventlistener (event. enter_frame, run );
Private function run (E: Event): void <br/>{< br/> for (var j: Int = 0; j <= 19; j ++) <br/>{< br/> list [J]. rotation + = 5; <br/> // trace (list [J-1]. x); <br/>}</P> <p>}
This effect will come out.
Package <br/> {<br/> Import flash. display. movieclip; <br/> Import flash. events. *; </P> <p> public class example extends movieclip <br/>{< br/> private var list: array = new array; <br/> private var angle: number = 36; <br/> private var R: Int = 150; <br/> Public Function example () <br/>{< br/> Init (); <br/> addeventlistener (event. enter_frame, run); <br/>}< br/> private function Init (): void <br/>{< br/> for (var I: Int = 0; I <20; I ++) <br/> {<br/> // var G: Number = angle * I * Math. PI/180; <br/> var ball: ball = new ball (); <br/> addchild (ball); <br/> list. push (ball); <br/> ball. X = 50; <br/> ball. y = 60; <br/> trace (list [I] + I); </P> <p >}< br/> for (VAR J: Int = 0; j <= 18; j ++) <br/>{< br/> list [J + 1]. X = list [J]. X + 20; <br/> list [J + 1]. y = list [J]. Y + 15; <br/> // trace (list [J-1]. x); <br/>}< br/> private function run (E: Event ): void <br/> {<br/> for (var j: Int = 0; j <= 19; j ++) <br/>{< br/> list [J]. rotation + = 5; <br/> // trace (list [J-1]. x); <br/>}</P> <p >}< br/>}
Iii. Transformation Algorithm
Compress some trivial code above into a parameter equation.
For (var I: Int = 0; I <20; I ++) <br/> {<br/> // var G: Number = angle * I * Math. PI/180; <br/> var ball: ball = new ball (); <br/> addchild (ball); <br/> list. push (ball); <br/> list [I]. X + = 50 + I * 20 * Math. cos (30 * Math. PI/180); <br/> list [I]. Y + = 60 + I * 20 * Math. sin (30 * Math. PI/180); <br/> trace ("DD"); </P> <p>}
In this way, the above results can be obtained, but the code requirements are much simpler.
When I = 0, the coordinates of the first ball list [0] are (50, 60)
When I = 1, the coordinate of the second small ball list [1] should be the first parameter for slope calculation. Line segments that run I * 20 at a tilt of 30 degrees. In this way, the second point is reached.
When I = 2 .....
.................
... Z until the end.
This is similar to a component formula of velocity.
VX = speed * Cos ();
Vy = speed * sin ();
This is a formula that we often use in physics. The application of the speed component.