I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com

velocity

Average and instantaneous velocity of an object
Controller: CodeCogs

Private project under development, to help contact the author: Contact Controller

Dependents

Info

Interface

C++
Excel

Overview

This module computes the average and instantaneous velocity of a moving object at given moments of time.

Authors

Lucian Bentea (July 2007)

Velocity Avg

 
doublevelocity_avgdoublexf
doubletf
doublex0 = 0
doublet0 = 0 )[inline]
This function computes the average velocity of a moving object, given its initial and final position on an axis and also the total time spent to get to that final position. Considering \inline  x_0 is the initial position at time \inline  t_0 and \inline  x_f is the final position at time \inline  t_f, the average velocity \inline \overline{v} is given by the following simple formula:

Example 1

#include <codecogs/physics/kinematics/velocity.h>
#include <iostream>
 
int main()
{
  // final position and time
  double x = 100, t = 15.7;
 
  std::cout << std::endl;
  std::cout << "  Final position = " << x << " m" << std::endl;
  std::cout << "      Time spent = " << t << " s" << std::endl;
  std::cout << std::endl;
 
  // assuming initial position and initial time are null,
  // display the average velocity of the object
 
  std::cout << "Average velocity = " << 
  Physics::Kinematics::velocity_avg(x, t);
  std::cout << " m/s" << std::endl;
 
  return 0;
}
Output
Final position = 100 m
      Time spent = 15.7 s
 
Average velocity = 6.36943 m/s

Parameters

xffinal position on the axis (meters)
tffinal time (seconds) [needs to be different from t0]
x0Default value = 0
t0Default value = 0

Returns

the average velocity of the moving object (meters per second)
Source Code

This module is private, for owner's use only.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Velocity Ins

 
doublevelocity_insdouble(*x)(double)[function pointer]
doublet
doubleeps = 1E-6 )[inline]
This function returns the instantaneous velocity of a moving object at a certain moment of time t, given a function x which determines the position of the object at any moment of time. It is based on the fact that the instantaneous velocity function \inline  v(t) is given by the derivative of the position function \inline  x(t) with respect to time, i.e.

Since this function uses numerical differentiation to compute the above derivative, an optional parameter eps is available to specify the precision of numerical computations.

Example 2

#include <codecogs/physics/kinematics/velocity.h>
#include <iostream>
 
// function defining the position at any moment of time t;
// in this case pos(t) = t^3
 
double pos(double t)
{
  return t*t*t;
}
 
int main()
{
  // time at which to calculate instantaneous velocity
  double t = 11.43;
 
  std::cout << std::endl;
  std::cout << "Position = " << pos(t);
  std::cout << " m" << std::endl;
  std::cout << "    Time = " << t;
  std::cout << " s" << std::endl;
  std::cout << std::endl;
 
  // display instantaneous velocity at time t
 
  std::cout << "Instantaneous velocity = " <<
  Physics::Kinematics::velocity_ins(space, t);
  std::cout << " m/s" << std::endl;
 
  return 0;
}
Output
Position = 1493.27 m
    Time = 11.43 s
 
Instantaneous velocity = 391.935 m/s

Parameters

xfunction defining the position of the object at any moment of time (meters)
tthe moment of time at which the instantaneous velocity is to be evaluated (seconds)
epsDefault value = 1E-6

Returns

the instantaneous velocity of the object at time t (meters per second)
Source Code

This module is private, for owner's use only.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Velocity Ins

 
std::vector<double>velocity_insdouble(*x)(double)[function pointer]
std::vector<double>& t
doubleeps = 1E-6 )[inline]
This function is based on the same equation as the previous one, only that it is able to compute the instantaneous velocities at several moments of time and return the results in the form of an array.

Notice the example code below which shows exactly how this is a generalisation of the previous overloaded function.

Example 3

#include <codecogs/physics/kinematics/velocity.h>
#include <iostream>
 
// function defining the position at any moment of time t;
// in this case pos(t) = t^3
 
double pos(double t)
{
  return t*t*t;
}
 
int main()
{
  // moments of time at which to evaluate 
  // the instantaneous velocity of the object
 
  double t[10] = { 
  11.40, 11.41, 11.42, 11.43, 11.44, 
  11.45, 11.46, 11.47, 11.48, 11.49
  };
 
  // compute the instantaneous velocities
 
  std::vector<double> time(t, t+10),
  velocities = Physics::Kinematics::velocity_ins(distance, time);
 
  // display the time, the position
  // and the instantaneous velocities
 
  std::cout << std::endl;
  for (int i = 0; i < 10; i++)
  {
    std::cout << "Time = " << time[i] << " s";
    std::cout << "\tPosition = " << pos(time[i]) << " m";
    std::cout << "\tVelocity = " << velocities[i] << " m/s";
    std::cout << std::endl;
  }
 
  return 0;
}
Output
Time = 11.4 s   Position = 1481.54 m    Velocity = 389.88 m/s
Time = 11.41 s  Position = 1485.45 m    Velocity = 390.564 m/s
Time = 11.42 s  Position = 1489.36 m    Velocity = 391.249 m/s
Time = 11.43 s  Position = 1493.27 m    Velocity = 391.935 m/s
Time = 11.44 s  Position = 1497.19 m    Velocity = 392.621 m/s
Time = 11.45 s  Position = 1501.12 m    Velocity = 393.307 m/s
Time = 11.46 s  Position = 1505.06 m    Velocity = 393.995 m/s
Time = 11.47 s  Position = 1509 m       Velocity = 394.683 m/s
Time = 11.48 s  Position = 1512.95 m    Velocity = 395.371 m/s
Time = 11.49 s  Position = 1516.91 m    Velocity = 396.06 m/s

Parameters

xfunction defining the position of the object at any moment of time (meters)
tarray containing the moments of time at which the instantaneous velocities should be evaluated (seconds)
epsDefault value = 1E-6

Returns

array containing the instantaneous velocities of the object at moments of time given by t (meters per second)
Source Code

This module is private, for owner's use only.

Not a member, then Register with CodeCogs. Already a Member, then Login.