# Tiro Parabolico

Line 1: | Line 1: | ||

− | + | <!-- Page info --> | |

− | + | {{Title|Tiro Parabolico}} | |

+ | {{Category|Tutorials}} | ||

+ | {{Category|Tutorials Advanced}} | ||

+ | <!-- Page info end --> | ||

− | + | Este es un pequeño tutorial para mostrar cómo hacer que un objeto siga el camino trazado por una finción matemática, como {{l|Requested Tutorials|requested here}}. | |

+ | |||

+ | ESTA PÁGINA ESTÁ SIENDO TRADUCIDA. TEN UN POCO DE PACIENCIA. GRACIAS. | ||

+ | |||

+ | == Función mathematical function a seguir == | ||

+ | |||

+ | Vamos a simular un disparo de cañón. Una bala describe una trayectoria parabólica tras ser disparada por el cañón.es | ||

{{l|Image:Parabolic-shot.gif}} | {{l|Image:Parabolic-shot.gif}} | ||

− | + | Las ecuaciones matemáticas que describen la trayectoria son: | |

<math>X(t)=V_{0x}\cdot t+X_0</math> | <math>X(t)=V_{0x}\cdot t+X_0</math> | ||

Line 12: | Line 21: | ||

<math>Y(t)=-\frac{1}{2}\cdot G \cdot t^2 + V_{0y}\cdot t + Y_0</math> | <math>Y(t)=-\frac{1}{2}\cdot G \cdot t^2 + V_{0y}\cdot t + Y_0</math> | ||

− | + | donde: | |

− | <math>t</math> = | + | <math>t</math> = tiempo actual para la ecuación. |

− | <math>X</math> = | + | <math>X</math> = coordenada 'x' de la bala en el tiempo 't' |

− | <math>Y</math> = | + | <math>Y</math> = coordenada 'y' de la bala en el tiempo 't' |

− | <math>X_0</math> = | + | <math>X_0</math> = posición 'x' de la bala en el tiempo t = 0 |

− | <math>Y_0</math> = | + | <math>Y_0</math> = posición 'y' de la bala en el tiempo t = 0 |

− | <math>V_{0x}</math> = | + | <math>V_{0x}</math> = componente 'x' de la velocidad en el momento del disparo (t = 0) |

− | <math>V_{0y}</math> = | + | <math>V_{0y}</math> = componente 'y' de la velocidad en el momento del disparo (t = 0) |

− | <math>G</math> = | + | <math>G</math> = aceleración de la gravedad. |

− | + | Normalmente tenemos el ángulo del tiro y la velocidad en lugar de sus componentes. Su descomposición es muy fácil: | |

<math>V_{0x} = V_0 \cdot \cos \varphi</math> | <math>V_{0x} = V_0 \cdot \cos \varphi</math> | ||

Line 36: | Line 45: | ||

<math>V_{0y} = V_0 \cdot \sin \varphi</math> | <math>V_{0y} = V_0 \cdot \sin \varphi</math> | ||

− | where: | + | donde: |

+ | |||

+ | <math>V_0</math> = velocidad al disparar (t = 0) | ||

+ | |||

+ | <math>\varphi</math> = ángulo del disparo del cañón con la horizontal. | ||

+ | |||

+ | Mira [http://en.wikipedia.org/wiki/Trajectory_of_a_projectile this Wikipedia article] si necesitas más información sobre las ecuaciones correspondientes al tiro parabólico. | ||

+ | |||

+ | == Separando las funciones == | ||

+ | |||

+ | So, how can we introduce these functions into Synfig?. To do that you should split the equations into their components. Once decomposed then you realize how many independent variables you need for the simulation. Also you will discover what are the 'engines' for the animation and what are parameters. | ||

+ | |||

+ | Let's start with the X coordinate: | ||

+ | |||

+ | <math>X=V_{0x}\cdot t+X_0</math> | ||

+ | |||

+ | Applying basic maths rules you can see that the function is composed by: | ||

+ | |||

+ | # The addition of two terms: (V0x*t) '''+''' (X0) | ||

+ | # The first term is a multiplication of two single terms: (V0x) '''*''' (t) | ||

+ | # And the third term is a single term (X0) | ||

+ | |||

+ | So to convert those formula into a Synfig understandable way you should create the following conversion types (between parentheses are the conversion types and between brackets are the exported values or the current values if not exported: | ||

+ | |||

+ | :[X] (Add) | ||

+ | ::LHS [X0] | ||

+ | ::RHS [X0] (Scale) | ||

+ | :::Link [V0x] | ||

+ | :::Scalar [t] | ||

+ | ::Scalar [1.0] | ||

+ | |||

+ | (Notice that the Scalar parameter from the Add convert type is not used so its value is 1.0) | ||

+ | |||

+ | So with this conversion type X becomes X0+(V0x*t). | ||

+ | |||

+ | Let's continue with the Y coordinate: | ||

+ | |||

+ | <math>Y=-\frac{1}{2}\cdot G \cdot t^2 + V_{0y}\cdot t + Y_0</math> | ||

+ | |||

+ | This one is a little more complicated because there are more terms. Anyway you should always try to group the terms in pairs and see what operator is used. Take care on the arithmetic operators properties (commutative, associative, distributive and identity) to respect the final values of the formulae. We will search for the operators with the lower order of precedence (multiplication, division and modulus precede addition and subtraction). | ||

+ | |||

+ | So there are two '+' operators what gives three terms: (-0.5*G*t²) + (V0y*t) + (Y0). Then since Synfig has only a two term convert type for addition operation, we need to make the Add conversion twice. | ||

+ | |||

+ | Continuing with the analysis, the individual terms are composed by multiplied terms: (-0.5) * (G) * (t²) and (V0y) * (t). | ||

+ | |||

+ | The same problem arises again; Synfig has a conversion type called 'Scale' that gives the multiplication of a Link by an Scalar. So we need to make the Scale conversion several times for the first term (in fact three times due to the fact that t²=t*t), and once for the second term. | ||

+ | |||

+ | So the final result is this: | ||

+ | |||

+ | :Y (Add) | ||

+ | ::LHS (Scale) | ||

+ | :::Link (Scale) | ||

+ | ::::Link (Scale) | ||

+ | :::::Link [t] | ||

+ | :::::Scalar [t] | ||

+ | ::::Scalar [G] | ||

+ | :::Scalar [-0.5] | ||

+ | ::RHS (Add) | ||

+ | :::LHS (Scale) | ||

+ | ::::Link [V0y] | ||

+ | ::::Scalar [t] | ||

+ | :::RHS [Y0] | ||

+ | :::Scalar [1.0] | ||

+ | ::Scalar [1.0] | ||

+ | |||

+ | Now let's study the velocity composition with the velocity modulus and its shooting angle. | ||

+ | |||

+ | <math>V_{0x} = V_0 \cdot \cos \varphi</math> | ||

+ | |||

+ | <math>V_{0y} = V_0 \cdot \sin \varphi</math> | ||

+ | |||

+ | You can see that splitting these formulae is very simple once you have understood what Synfig needs: | ||

+ | |||

+ | :V0x (Cos) | ||

+ | ::Angle [phi] | ||

+ | ::Amplitude [V0] | ||

+ | |||

+ | and | ||

+ | |||

+ | :V0y (Sin) | ||

+ | ::Angle [phi] | ||

+ | ::Amplitude [V0] | ||

+ | |||

+ | == OK I've analysed the maths functions but how do I put them into Synfig? == | ||

+ | |||

+ | Well, in the example of the cannon and ball, I've assigned the X and Y values to the X and Y values of the centre of the circle that defines the bullet. You can assign the mathematical equations to any of the convertible parameters that exist in any layer. | ||

+ | |||

+ | So you have to go to the circle Center parameter, right click, and select 'Convert -> Composite' from the context menu. Once done you'll obtain two sub-parameters: 'X-axis' and 'Y-axis'. | ||

+ | |||

+ | All that you need to do is right click on the corresponding parameter that you obtain after each convert type and select the correct conversion type from the analysis you have done before. Then you will convert sequentially each sub-parameter to the proper one. | ||

+ | |||

+ | Once done you should export the most simple terms to allow easy modification by the user or to allow multiple links in the same formulae. For example the 't' variable (the time for the mathematical equation) is used several times. You should export it only once. The rest of times that 't' appears you should select the exported 't' Valuenode from the child dialog and right click and 'Connect' to connect with it. | ||

+ | |||

+ | Once done you should obtain something like this: | ||

+ | |||

+ | {{l|Image:Final-Convert-Result.png}} | ||

+ | |||

+ | == The 't' parameter == | ||

+ | |||

+ | In this case the 'engine' of the equations is the variable 't' (the physic time). To make the engine parameter to 'move' in the animation we need to link it to the animation's current time. To do that we are going to use the 'Linear' convert type. In fact this one is the only convert type that allows a parameter to change with the animation time. It is really important to understand how it works because it will allow us to add 'motion' to our mathematical equations. | ||

+ | |||

+ | The '{{l|Convert#Linear|Linear}}' convert type gives two sub-parameters: | ||

+ | |||

+ | '''Rate''': is the amount of change of the converted parameter in one second of animation time. | ||

+ | |||

+ | '''Offset''': is an offset value to add to the result of the multiplication of the animation time by the Rate value. | ||

+ | |||

+ | So if the converted type is 't' we will obtain: | ||

+ | |||

+ | t = Rate*T+Offset | ||

+ | |||

+ | where T is the current animation time in seconds. | ||

+ | |||

+ | You should have notice that in the image of the conversion types result, the 't' parameter is also converted. It was not expanded in order not to complicate the sample. Here is the result: | ||

+ | |||

+ | {{l|Image:Time-convert.png}} | ||

+ | |||

+ | I've exported the Offset parameter to 't1' to allow easy manipulation during the animation. | ||

+ | |||

+ | == Setting up the parameters == | ||

+ | |||

+ | Once done all the conversions and all the exportations you can go to the Child ValueNode list and insert the proper values for the parameters of the animation: V0, phi, G, X0, Y0, t1 | ||

+ | |||

+ | The X-axis and Y-axis parameters are calculated based on the variation of the 't' parameter that is linear with the animation time T. You can also export the parameter 'Rate' form the converted type 't' if you want extra external variation of the equation motion. | ||

+ | Test the values of the mentioned animation parameters to the desired ones. Specially some combinations of G and V0 gives good or bad values. I've set G=2.0 so my example is not in the earth :) | ||

+ | |||

+ | == Producing more than one shot == | ||

+ | |||

+ | You have notice that the shot animation is a little boring due to it starts at time T=0 and there is only one shot. How can you do the same than the sample? How can I use the same bullet several times making different shots with different angles, positions and initial velocities? Quite easy. Use the Offset parameter form the Linear conversion of the 't' variable. | ||

+ | |||

+ | Initially the Offset parameter is set to 0.0. That means that t=T or in other hands, the animation time is the same than the equation time. But what happen if you modify the Offset parameter during the animation?. You can 'rewind' the equation motion to the place you want just inserting the proper values of the Offset parameter at the proper animation time. | ||

+ | |||

+ | {|border="1" cellspacing="0" align="center" | ||

+ | |T (sec)|| Offset (t units) || Rate (t units/sec)||t = Rate*T+Offset||Offset waypoint (in/out) | ||

+ | |- | ||

+ | |0.0||0.0||2.0||0.0|| linear/linear | ||

+ | |- | ||

+ | |0.5||-1.0||2.0||0.0|| linear/linear | ||

+ | |- | ||

+ | |4.0||-8.0||2.0||0.0|| constant/linear | ||

+ | |- | ||

+ | |5.5||-11.0||2.0||0.0|| linear/linear | ||

+ | |} | ||

+ | |||

+ | Those are the graphical representation for the above values: | ||

+ | |||

+ | '''Offset curve''': | ||

+ | |||

+ | {{l|Image:Offset-curve.png}} | ||

+ | |||

+ | '''Rate curve''': | ||

+ | |||

+ | {{l|Image:Rate-curve.png}} | ||

+ | |||

+ | ''''t' curve''': | ||

+ | |||

+ | {{l|Image:t-Curve.png}} | ||

+ | |||

+ | |||

+ | |||

+ | Notice that between T=0 and T=0.5 the Offset value has a linear variation that is inverse to the current Rate (2.0). It produces a no variation on the 't' parameter. | ||

+ | |||

+ | Also when Offset is set to constant = -1.0 (between T=0.5 and T=4.0 seconds) the 't' curve becomes linear (according to the value of Rate). During that period of time the equation is in 'action' and the parabolic shot is done with the current values of X0, Y0, V0, phi and G. | ||

+ | |||

+ | When Offset is suddenly set to -8.0 at T=4.0 it produces a 'rewind' of the equation animation to its 'zero' (t=Rate*T+Offset=2.0*4.0-8.0=0.0) so the bullet comes again to its origin. | ||

+ | |||

+ | Notice again that between T=4 and T=5.5 the Offset parameter has a linear variation between -8.0 and -11.0 (what comes from the current T value, divided by the Rate and changed sign), what gives a 't' result constant and equal to 0.0. | ||

+ | |||

+ | Again, from T=5.5 and beyond, the Offset is set to constant (there is no waypoint later so the value is kept) and the 't' value becomes linear (again there is a second shot). But in this case at T=5.5 the other parameters have been set to other different values (angle is higher and initial velocity is lower) using a constant waypoint. It allows to simulate a new shot with different parameters. | ||

+ | |||

+ | == The file link and other comments == | ||

− | + | The above animation can be found also at [http://www.youtube.com/watch?v=Zzs3a52De-I youtube]. The result sifz file for that animation is [http://www.darthfurby.com/genete/synfig/parabolic-shot.sifz here]. | |

− | + | I've added a fancy shooting cannon (it has a rotation angle linked to the 'phi' parameter) a motion blur on the bullet and some background. | |

− | + | I hope you enjoyed the tutorial. If need any help please ask it in any of the {{l|Contact|usual places}}. |

## Revision as of 12:19, 13 October 2011

Warning!
The release of Synfig Studio 0.64.0 introduced new terminology and this translated page needs to be updated according to original English text. You can help updating this page - see instructions here. Thank you! |

Este es un pequeño tutorial para mostrar cómo hacer que un objeto siga el camino trazado por una finción matemática, como requested here.

ESTA PÁGINA ESTÁ SIENDO TRADUCIDA. TEN UN POCO DE PACIENCIA. GRACIAS.

## Contents

## Función mathematical function a seguir

Vamos a simular un disparo de cañón. Una bala describe una trayectoria parabólica tras ser disparada por el cañón.es

Las ecuaciones matemáticas que describen la trayectoria son:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle X(t)=V_{0x}\cdot t+X_0}**

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle Y(t)=-\frac{1}{2}\cdot G \cdot t^2 + V_{0y}\cdot t + Y_0}**

donde:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle t}**
= tiempo actual para la ecuación.

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle X}**
= coordenada 'x' de la bala en el tiempo 't'

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle Y}**
= coordenada 'y' de la bala en el tiempo 't'

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle X_0}**
= posición 'x' de la bala en el tiempo t = 0

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle Y_0}**
= posición 'y' de la bala en el tiempo t = 0

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0x}}**
= componente 'x' de la velocidad en el momento del disparo (t = 0)

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0y}}**
= componente 'y' de la velocidad en el momento del disparo (t = 0)

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle G}**
= aceleración de la gravedad.

Normalmente tenemos el ángulo del tiro y la velocidad en lugar de sus componentes. Su descomposición es muy fácil:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0x} = V_0 \cdot \cos \varphi}**

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0y} = V_0 \cdot \sin \varphi}**

donde:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_0}**
= velocidad al disparar (t = 0)

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle \varphi}**
= ángulo del disparo del cañón con la horizontal.

Mira this Wikipedia article si necesitas más información sobre las ecuaciones correspondientes al tiro parabólico.

## Separando las funciones

So, how can we introduce these functions into Synfig?. To do that you should split the equations into their components. Once decomposed then you realize how many independent variables you need for the simulation. Also you will discover what are the 'engines' for the animation and what are parameters.

Let's start with the X coordinate:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle X=V_{0x}\cdot t+X_0}**

Applying basic maths rules you can see that the function is composed by:

- The addition of two terms: (V0x*t)
**+**(X0) - The first term is a multiplication of two single terms: (V0x)
*****(t) - And the third term is a single term (X0)

So to convert those formula into a Synfig understandable way you should create the following conversion types (between parentheses are the conversion types and between brackets are the exported values or the current values if not exported:

- [X] (Add)
- LHS [X0]
- RHS [X0] (Scale)
- Link [V0x]
- Scalar [t]

- Scalar [1.0]

(Notice that the Scalar parameter from the Add convert type is not used so its value is 1.0)

So with this conversion type X becomes X0+(V0x*t).

Let's continue with the Y coordinate:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle Y=-\frac{1}{2}\cdot G \cdot t^2 + V_{0y}\cdot t + Y_0}**

This one is a little more complicated because there are more terms. Anyway you should always try to group the terms in pairs and see what operator is used. Take care on the arithmetic operators properties (commutative, associative, distributive and identity) to respect the final values of the formulae. We will search for the operators with the lower order of precedence (multiplication, division and modulus precede addition and subtraction).

So there are two '+' operators what gives three terms: (-0.5*G*t²) + (V0y*t) + (Y0). Then since Synfig has only a two term convert type for addition operation, we need to make the Add conversion twice.

Continuing with the analysis, the individual terms are composed by multiplied terms: (-0.5) * (G) * (t²) and (V0y) * (t).

The same problem arises again; Synfig has a conversion type called 'Scale' that gives the multiplication of a Link by an Scalar. So we need to make the Scale conversion several times for the first term (in fact three times due to the fact that t²=t*t), and once for the second term.

So the final result is this:

- Y (Add)
- LHS (Scale)
- Link (Scale)
- Link (Scale)
- Link [t]
- Scalar [t]

- Scalar [G]

- Link (Scale)
- Scalar [-0.5]

- Link (Scale)
- RHS (Add)
- LHS (Scale)
- Link [V0y]
- Scalar [t]

- RHS [Y0]
- Scalar [1.0]

- LHS (Scale)
- Scalar [1.0]

- LHS (Scale)

Now let's study the velocity composition with the velocity modulus and its shooting angle.

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0x} = V_0 \cdot \cos \varphi}**

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle V_{0y} = V_0 \cdot \sin \varphi}**

You can see that splitting these formulae is very simple once you have understood what Synfig needs:

- V0x (Cos)
- Angle [phi]
- Amplitude [V0]

and

- V0y (Sin)
- Angle [phi]
- Amplitude [V0]

## OK I've analysed the maths functions but how do I put them into Synfig?

Well, in the example of the cannon and ball, I've assigned the X and Y values to the X and Y values of the centre of the circle that defines the bullet. You can assign the mathematical equations to any of the convertible parameters that exist in any layer.

So you have to go to the circle Center parameter, right click, and select 'Convert -> Composite' from the context menu. Once done you'll obtain two sub-parameters: 'X-axis' and 'Y-axis'.

All that you need to do is right click on the corresponding parameter that you obtain after each convert type and select the correct conversion type from the analysis you have done before. Then you will convert sequentially each sub-parameter to the proper one.

Once done you should export the most simple terms to allow easy modification by the user or to allow multiple links in the same formulae. For example the 't' variable (the time for the mathematical equation) is used several times. You should export it only once. The rest of times that 't' appears you should select the exported 't' Valuenode from the child dialog and right click and 'Connect' to connect with it.

Once done you should obtain something like this:

## The 't' parameter

In this case the 'engine' of the equations is the variable 't' (the physic time). To make the engine parameter to 'move' in the animation we need to link it to the animation's current time. To do that we are going to use the 'Linear' convert type. In fact this one is the only convert type that allows a parameter to change with the animation time. It is really important to understand how it works because it will allow us to add 'motion' to our mathematical equations.

The 'Linear' convert type gives two sub-parameters:

**Rate**: is the amount of change of the converted parameter in one second of animation time.

**Offset**: is an offset value to add to the result of the multiplication of the animation time by the Rate value.

So if the converted type is 't' we will obtain:

t = Rate*T+Offset

where T is the current animation time in seconds.

You should have notice that in the image of the conversion types result, the 't' parameter is also converted. It was not expanded in order not to complicate the sample. Here is the result:

I've exported the Offset parameter to 't1' to allow easy manipulation during the animation.

## Setting up the parameters

Once done all the conversions and all the exportations you can go to the Child ValueNode list and insert the proper values for the parameters of the animation: V0, phi, G, X0, Y0, t1

The X-axis and Y-axis parameters are calculated based on the variation of the 't' parameter that is linear with the animation time T. You can also export the parameter 'Rate' form the converted type 't' if you want extra external variation of the equation motion. Test the values of the mentioned animation parameters to the desired ones. Specially some combinations of G and V0 gives good or bad values. I've set G=2.0 so my example is not in the earth :)

## Producing more than one shot

You have notice that the shot animation is a little boring due to it starts at time T=0 and there is only one shot. How can you do the same than the sample? How can I use the same bullet several times making different shots with different angles, positions and initial velocities? Quite easy. Use the Offset parameter form the Linear conversion of the 't' variable.

Initially the Offset parameter is set to 0.0. That means that t=T or in other hands, the animation time is the same than the equation time. But what happen if you modify the Offset parameter during the animation?. You can 'rewind' the equation motion to the place you want just inserting the proper values of the Offset parameter at the proper animation time.

T (sec) | Offset (t units) | Rate (t units/sec) | t = Rate*T+Offset | Offset waypoint (in/out) |

0.0 | 0.0 | 2.0 | 0.0 | linear/linear |

0.5 | -1.0 | 2.0 | 0.0 | linear/linear |

4.0 | -8.0 | 2.0 | 0.0 | constant/linear |

5.5 | -11.0 | 2.0 | 0.0 | linear/linear |

Those are the graphical representation for the above values:

**Offset curve**:

**Rate curve**:

'**t' curve**:

Notice that between T=0 and T=0.5 the Offset value has a linear variation that is inverse to the current Rate (2.0). It produces a no variation on the 't' parameter.

Also when Offset is set to constant = -1.0 (between T=0.5 and T=4.0 seconds) the 't' curve becomes linear (according to the value of Rate). During that period of time the equation is in 'action' and the parabolic shot is done with the current values of X0, Y0, V0, phi and G.

When Offset is suddenly set to -8.0 at T=4.0 it produces a 'rewind' of the equation animation to its 'zero' (t=Rate*T+Offset=2.0*4.0-8.0=0.0) so the bullet comes again to its origin.

Notice again that between T=4 and T=5.5 the Offset parameter has a linear variation between -8.0 and -11.0 (what comes from the current T value, divided by the Rate and changed sign), what gives a 't' result constant and equal to 0.0.

Again, from T=5.5 and beyond, the Offset is set to constant (there is no waypoint later so the value is kept) and the 't' value becomes linear (again there is a second shot). But in this case at T=5.5 the other parameters have been set to other different values (angle is higher and initial velocity is lower) using a constant waypoint. It allows to simulate a new shot with different parameters.

## The file link and other comments

The above animation can be found also at youtube. The result sifz file for that animation is here.

I've added a fancy shooting cannon (it has a rotation angle linked to the 'phi' parameter) a motion blur on the bullet and some background.

I hope you enjoyed the tutorial. If need any help please ask it in any of the usual places.