00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <vamos/body/Contact_Point.h>
00022
00023
00024
00025 Vamos_Body::Contact_Point::
00026 Contact_Point (double mass, const Vamos_Geometry::Three_Vector& position,
00027 const Vamos_Geometry::Three_Matrix& orientation,
00028 Vamos_Geometry::Material::Material_Type type,
00029 double friction, double restitution)
00030 : Particle (mass, position, orientation),
00031 m_contact (false)
00032 {
00033 m_material = new Vamos_Geometry::Material (type, friction, restitution);
00034 }
00035
00036
00037 Vamos_Body::Contact_Point::
00038 Contact_Point (double mass, const Vamos_Geometry::Three_Vector& position,
00039 Vamos_Geometry::Material::Material_Type type,
00040 double friction, double restitution )
00041 : Particle (mass, position),
00042 m_contact (false)
00043 {
00044 m_material = new Vamos_Geometry::Material (type, friction, restitution);
00045 }
00046
00047
00048 Vamos_Body::Contact_Point::
00049 Contact_Point ()
00050 {
00051 }
00052
00053
00054
00055
00056
00057 double Vamos_Body::Contact_Point::
00058 contact (const Vamos_Geometry::Three_Vector& position,
00059 const Vamos_Geometry::Inertia_Tensor& inertia,
00060 const Vamos_Geometry::Three_Vector& velocity,
00061 double,
00062 const Vamos_Geometry::Three_Vector& normal,
00063 const Vamos_Geometry::Three_Vector& ang_velocity,
00064 Vamos_Geometry::Material_Handle material)
00065 {
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 Vamos_Geometry::Three_Vector v_perp = rotate_in (velocity.project (normal));
00077
00078
00079 double meff = inertia.inertia (position, normal);
00080 m_impulse = -(1.0 + (m_material->restitution_factor ()
00081 * material->restitution_factor ())) * meff * v_perp;
00082
00083 Vamos_Geometry::Three_Vector v_par = rotate_in (velocity) - v_perp;
00084 m_impulse -= v_par.unit () * m_material->friction_factor ()
00085 * material->friction_factor () * m_impulse.abs ();
00086
00087 m_contact = true;
00088
00089 return 0;
00090 }
00091
00092
00093
00094
00095 void Vamos_Body::Contact_Point::
00096 find_forces ()
00097 {
00098 if (!m_contact)
00099 {
00100 m_force.zero ();
00101 m_impulse.zero ();
00102 m_torque.zero ();
00103 }
00104 }
00105
00106
00107 void Vamos_Body::Contact_Point::
00108 end_timestep ()
00109 {
00110 m_contact = false;
00111 }