[go: up one dir, main page]

Menu

[f338fb]: / body / Contact_Point.cc  Maximize  Restore  History

Download this file

95 lines (83 with data), 2.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Contact_Point.cc - a particle that responds to collisions.
//
// Copyright (C) 2002 Sam Varner
//
// This file is part of Vamos Automotive Simulator.
//
// Vamos is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vamos is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vamos. If not, see <http://www.gnu.org/licenses/>.
#include "Contact_Point.h"
using namespace Vamos_Geometry;
using namespace Vamos_Body;
//* Constructors
Contact_Point::Contact_Point (double mass,
const Three_Vector& position,
const Three_Matrix& orientation,
Material::Material_Type type,
double friction,
double restitution,
const Frame* parent)
: Particle (mass, position, orientation, parent),
m_contact (false)
{
set_material (Material (type, friction, restitution));
}
// Take the parent's orientation.
Contact_Point::Contact_Point (double mass,
const Three_Vector& position,
Material::Material_Type type,
double friction,
double restitution,
const Frame* parent)
: Particle (mass, position, parent),
m_contact (false)
{
set_material (Material (type, friction, restitution));
}
Contact_Point::Contact_Point (const Particle& particle,
const Material& material)
: Particle (particle),
m_contact (false)
{
set_material (material);
}
// Handle collisions. The return value is how much the particle has
// moved as a result of the contact. For a Particle, this is always
// 0. But, for derived classes that model moving parts, a non-zero
// value may be returned.
double
Contact_Point::contact (const Three_Vector& impulse,
const Three_Vector& velocity,
double distance,
const Three_Vector& normal,
const Three_Vector& angular_velocity,
const Material& material)
{
set_impulse (rotate_from_parent (impulse));
m_contact = true;
return 0.0;
}
// Find and store the forces and torques for the current
// configuration.
void
Contact_Point::find_forces ()
{
if (!m_contact)
reset ();
}
// Do any neccary cleanup at the end of a time step.
void
Contact_Point::end_timestep ()
{
m_contact = false;
}