calc_face_vertex_velocity.cpp
2 
3 using namespace std;
4 
5 Vector2D calc_face_vertex_velocity(const Vector2D& p1_pos, const Vector2D& p1_vel,
6  const Vector2D& p2_pos, const Vector2D& p2_vel,
7  const Vector2D& vertex)
8 {
9  const Vector2D center = 0.5*(p2_pos + p1_pos);
10  const Vector2D n = (p2_pos - p1_pos)/abs(p2_pos-p1_pos);
11  const Vector2D p = zcross(p2_pos-p1_pos)/abs(zcross(p2_pos-p1_pos));
12 
13  return 0.5*(p1_vel+p2_vel)+
14  p*ScalarProd(p2_vel-p1_vel,n)*ScalarProd(vertex-center,p)/abs(p2_pos-p1_pos)-
15  n*ScalarProd(p2_vel-p1_vel,p)*ScalarProd(vertex-center,p)/abs(p2_pos-p1_pos);
16 }
17 
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
Definition: Vector3D.cpp:185
Vector2D calc_face_vertex_velocity(const Vector2D &p1_pos, const Vector2D &p1_vel, const Vector2D &p2_pos, const Vector2D &p2_vel, const Vector2D &vertex)
Calculates the velocity of the vertices of a Voronoi face.
Calculates the velocity of the vertices of a Voronoi face.
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
2D Mathematical vector
Definition: geometry.hpp:15
Vector2D zcross(Vector2D const &v)
Cross product of a vector in x,y plane with a unit vector in the z direction.
Definition: geometry.cpp:145