Basic trigonometric functions and applications

Source: Internet
Author: User
Tags cos function definition sin

1. Coordinate system:

Flash coordinate system and mathematical coordinate system: the X axis is the same, and the y axis is the opposite.

[Mathematical coordinate system]
[Coordinate system in Flash]

2. Conversion between Angle and Radian:

(1) radians: radians = angle * PI/180;

(2) angle: angle = Radian * 180/PI;

* The angle is mostly used in. _ rotation.

* Radians are mostly used for sin (), cos (), atan ()......

3. Sine, cosine, and tangent:
1> sine: Math. sin (n); use its image properties in Flash:


As X grows, the value of Y is [, 0.

2> cosine: Math. cos (n). The usage is similar to that of Math. cos.


As X grows, the value of Y is.

3> tangent: Math. atan2 (y, x)
This parameter is used to calculate the angle between two points.


Math. atan2 (y, x) and Math. atan (n) functions the same, but the returned values are different:

The return value of atan2 (x, y) is a number.

The return value of atan (n) is from
-PI/2 ~ PI/2


<
The above are some theoretical knowledge. Here are some specific application examples.
>>>
4. Sine example:

Idea: use sin (n) to control the y axis of mc
Step 1:

   
Create a Ball type and store it as MC. The instance name is "Ball" and put it on the stage.
Step 2:
Add the AS code layer:
Var A =
80;
// Set the amplitude

Var centerY = 150;
// Set the display position

Var n = 0;
// Accumulate variable

OnEnterFrame =
Function (){

Ball. _ y =
CenterY + A * (-1 * Math. sin (n * Math. PI/180 ));
// Change the y coordinate of the ball to display the sine wave.


N + = 10;

};


5. Tangent instance:

Idea: use tan2 (x, y) to calculate the angle and obtain the angle change
Mc. _ rotation.
Step 1:

   
Draw out the eye, nose, and mouth as the background;

   
Draw a black circle as the eyes and save it as MC. The instance name is "Reye". The registration point is in the middle left.

   
Copy a Reye instance named "Leye" as another eye.
Step 2:
Add the AS code layer:
Reye. onMouseMove = function ()
{

Var dx = _ xmouse-this. _ x;

Var dy =
_ Ymouse-this. _ y;
// Obtain the distance between the mouse and the eye


Var theta =
Math. atan2 (dy,
Dx );
// Calculate the angle (in radians)

This. _ rotation =
Theta/Math. PI * 180;
// Convert to angle


};

Leye. onMouseMove =
Reye. onMouseMove;
// When the Leye mouse moves, the function is equal to the function when the Reye mouse moves.


6. Examples of sine and cosine synthesis:
1> circle method:


Cos (n) is used as the vertex x, and the x point ranges from 1 ~ 0 ~ -1 ~ 0



Use sin (n) as the point y, combination point x, [1, 0] ~ [0, 1] ~ [-1, 0] ~ [0,-1] ~ [1, 0]
Along, X axis = cos (n ),
Y axis = sin (n) route to draw the circle
1> AS Circle (important ):
Idea: 1. Create an empty video clip as a drawing container and draw it in the video clip;
   
2. The angle (n) increases from 0 degrees to 360 degrees;
   
3. The X coordinate is cos (n), and the Y coordinate is sin (n); n
To be expressed in radians;
_ Root. createEmptyMovieClip ("MC ",
1 );

MC. _ x = 200;

MC. _ y =
200;
// Create an empty video clip and place it in the middle of the stage as a painting line container


Var R =
60;
// Radius of the circle
MC. moveTo (R * Math. cos (0 ),
R * Math. sin (0 ));
// Start point of the starting line

MC. lineStyle (2 );

For (n = 1; n <360; n ++)
{

Angle = n * Math. PI/180;

Tox =
R * Math. cos (angle );

Toy =
R * Math. sin (angle );
// Parameter equation of the circle

MC. lineTo (tox, toy );

}

2> AS verbose (important ):
Idea: 1. The interior angle of the polygon is equal to or equal to 360 degrees;
   
2. Determine the angle of each vertex based on the number of edges;
   
3. Then, determine the position of each vertex based on the angle and connect each vertex.
_ Root. createEmptyMovieClip ("MC", 1 );

MC. _ x = 200;

MC. _ y = 200;

Var R = 50;
// Radius

Var sides = 5;
// Number of multiple sides

Var angle =
(360 * Math. PI/180)/sides;
// Equal to each other =
Radians (360 * PI/180)/sides of the circle;

MC. moveTo (R * Math. cos (0 ),
R * Math. sin (0 ));
// Draw the start point from the first angle

MC. lineStyle (2)

For (n = 1; n <= sides; n ++)
{

Var tox = R * Math. cos (n * angle );

Var toy = R * Math. sin (n * angle );

MC. lineTo (tox,
Toy );
// Link between two points

}

3> AS method for drawing a spiral (Archimedes spiral ):
Ideas:
1. Use polar coordinates;
2. The polar coordinate equation of the Archimedes spiral:
Ru (polar path) = a (offset) * & theta; (polar angle );
3. It can be simply understood as a circle with an increasing radius.
_ Root. createEmptyMovieClip ("MC", 1 );

MC. _ x = 200;

MC. _ y = 200;

Var R = 10;
// Radius length

Var a = 3;
// Offset

MC. moveTo (0, 0 );
// Draw from the center of the circle

MC. lineStyle (2 );

For (n = 1; n <360; n ++)
{

Var angle = a * (n * Math. PI/180 );

Var tox = angle * R * Math. cos (angle );

Var toy = angle * R * Math. sin (angle );
// Parameter equation of the spiral line


MC. lineTo (tox, toy );

}


Flash Charging: trigonometric function
   
Trigonometric function is a class of functions in mathematics that belong to an elementary function that surpasses a function. Essentially, they are the ing between the set of any angle and the variable of a specific ratio set. The normal trigonometric function is in the Cartesian coordinate system of the plane.
Defined. Its definition domain is the entire real number field. Another definition is in a right triangle, but not completely. Modern mathematics describes them as the limit of the infinite series and the solution of the differential equations, and extends their definitions to the plural series.
Due to the periodicity of trigonometric functions, it does not have an inverse function in the sense of single-valued functions.
Trigonometric functions are used in complex numbers. In physics, trigonometric functions are also common tools.


Basic content

It has six basic functions (basic expression ):
Function name: sine cosine tangent, cotangent, positive cut, and remainder cut
Sin & theta; = y/r
Cosine function cos & theta; = x/r
Tangent function tan & theta; = y/x
Cotangent function cot & theta; = x/y
Cut function sec & theta; = r/x
Cosine cut function csc & theta; = r/y
And two functions that are not commonly used and tend to be eliminated:

Positive vector function versin & theta; = 1-cos & theta;

Returns the cosine function vercos & theta; = 1-sin & theta;

The basic relationship between trigonometric functions in the same angle:

· Square relationship:

Sin ^ 2 (& alpha;) + cos ^ 2 (& alpha;) = 1

Tan ^ 2 (& alpha;) + 1 = sec ^ 2 (& alpha ;)

Cot ^ 2 (& alpha;) + 1 = csc ^ 2 (& alpha ;)

· Product relationship:

Sin & alpha; = tan & alpha; * cos & alpha;
Cos & alpha; = cot & alpha; * sin & alpha;

Tan & alpha; = sin & alpha; * sec & alpha;
Cot & alpha; = cos & alpha; * csc & alpha;

Sec & alpha; = tan & alpha; * csc & alpha;
Csc & alpha; = sec & alpha; * cot & alpha;

· Reciprocal relationship:

Tan & alpha; · cot & alpha; = 1

Sin & alpha; · csc & alpha; = 1

  
Cos & alpha; · sec & alpha; = 1

Trigonometric constant deformation formula:

· Trigonometric functions with two angles and difference:

Cos (& alpha; + & beta;) = cos & alpha; · cos & beta;-sin & alpha; · sin & beta;

Cos (& alpha;-& beta;) = cos & alpha; · cos & beta; + sin & alpha; · sin & beta;

Sin (& alpha; ± & beta;) = sin & alpha; · cos & beta; ± cos & alpha; · sin & beta;

Tan (& alpha; + & beta;) = (tan & alpha; + tan & beta;)/(1-tan & alpha; · tan & beta ;)

Tan (& alpha;-& beta;) = (tan & alpha;-tan & beta;)/(1 + tan & alpha; · tan & beta ;)

· Auxiliary angle formula:

Asin & alpha; + Bcos & alpha; = (A ^ 2 + B ^ 2) ^ (1/2) sin (& alpha; + t), where

Sint = B/(A ^ 2 + B ^ 2) ^ (1/2)

Cost = A/(A ^ 2 + B ^ 2) ^ (1/2)

· Angle X formula:

Sin (2 & alpha;) = 2sin & alpha; · cos & alpha;

Cos (2 & alpha;) = cos ^ 2 (& alpha;)-sin ^ 2 (& alpha;) = 2cos ^ 2 (& alpha ;) -1 = 1-2sin ^ 2 (& alpha ;)

Tan (2 & alpha;) = 2tan & alpha;/[1-tan ^ 2 (& alpha;)]

· Triple angle formula:

Sin3 & alpha; = 3sin & alpha;-4sin ^ 3 (& alpha ;)

Cos3 & alpha; = 4cos ^ 3 (& alpha;)-3cos & alpha;

· Halfwidth formula:

Sin ^ 2 (& alpha;/2) = (1-cos & alpha;)/2

Cos ^ 2 (& alpha;/2) = (1 + cos & alpha;)/2

Tan ^ 2 (& alpha;/2) = (1-cos & alpha;)/(1 + cos & alpha ;)

Tan (& alpha;/2) = sin & alpha;/(1 + cos & alpha;) = (1-cos & alpha;)/sin & alpha;

· Universal formula:

Sin & alpha; = 2tan (& alpha;/2)/[1 + tan ^ 2 (& alpha;/2)]

Cos & alpha; = [1-tan ^ 2 (& alpha;/2)]/[1 + tan ^ 2 (& alpha;/2)]

Tan & alpha; = 2tan (& alpha;/2)/[1-tan ^ 2 (& alpha;/2)]

· Formula of product and difference:

Sin & alpha; · cos & beta; = (1/2) [sin (& alpha; + & beta;) + sin (& alpha;-& beta;)]

Cos & alpha; · sin & beta; = (1/2) [sin (& alpha; + & beta;)-sin (& alpha;-& beta;)]

Cos & alpha; · cos & beta; = (1/2) [cos (& alpha; + & beta;) + cos (& alpha;-& beta;)]

Sin & alpha; · sin & beta; =-(1/2) [cos (& alpha; + & beta;)-cos (& alpha;-& beta;)]

· Sum-Difference product formula:

Sin & alpha; + sin & beta; = 2sin [(& alpha; + & beta;)/2] cos [(& alpha;-& beta;)/2]

Sin & alpha;-sin & beta; = 2cos [(& alpha; + & beta;)/2] sin [(& alpha;-& beta;)/2]

Cos & alpha; + cos & beta; = 2cos [(& alpha; + & beta;)/2] cos [(& alpha;-& beta;)/2]

Cos & alpha;-cos & beta; =-2sin [(& alpha; + & beta;)/2] sin [(& alpha;-& beta;)/2]

· Others:

Sin & alpha; + sin (& alpha; + 2 & pi;/n) + sin (& alpha; + 2 & pi; * 2/n) + sin (& alpha; + 2 & pi; * 3/n) + ...... + Sin [& alpha; + 2 & pi; * (n-1)/n] = 0


Cos & alpha; + cos (& alpha; + 2 & pi;/n) + cos (& alpha; + 2 & pi; * 2/n) + cos (& alpha; + 2 & pi; * 3/n) + ...... + Cos [& alpha; + 2 & pi; * (n-1)/n] = 0
And

Sin ^ 2 (& alpha;) + sin ^ 2 (& alpha;-2 & pi;/3) + sin ^ 2 (& alpha; + 2 & pi;/3) = 3/2

TanAtanBtan (A + B) + tanA + tanB-tan (A + B) = 0

Some advanced content:
· Exponential representation of trigonometric functions in Higher Algebra (derived from the Taylor series ):

Sinx = [e ^ (ix)-e ^ (-ix)]/2

Cosx = [e ^ (ix) + e ^ (-ix)]/2

Tanx = [e ^ (ix)-e ^ (-ix)]/[^ (ix) + e ^ (-ix)]

Taylor's expansion has an infinite series. e ^ z = exp (z) = 1 + z/1! + Z ^ 2/2! + Z ^ 3/3! + Z ^ 4/4! +... + Z ^ n/n! +...


At this time, the trigonometric function definition field has been extended to the entire complex number set.

· Trigonometric functions as solutions for differential equations:

For the differential equations y =-y ''; y = y ''', a general Q is provided, which proves

Q = Asinx + Bcosx. Therefore, the trigonometric function can be defined.

Supplement: we can define a similar function, a hyperbolic function, with many similar properties similar to trigonometric functions.


· Special trigonometric function value

A 30'
45'
60'
90'

Sina 1/2
& Radic; 2/2
& Amp; radic; 3/2 1


Cosa & amp; radic; 3/2
& Radic; 2/2
1/2
0

Tga
& Radic; 3/3
1     
& Amp; radic; 3 does not exist

Ctga & radic; 3
1   
& Radic; 3/3
0




This is the end of the tutorial.
QQ: 147461195 (FL Foundation master)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.