[go: up one dir, main page]

Menu

[f338fb]: / body / Transmission.h  Maximize  Restore  History

Download this file

90 lines (69 with data), 2.7 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
// Transmission.h - a gearbox for the drivetrain.
//
// Copyright (C) 2001--2004 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/>.
#ifndef _TRANSMISSION_H_
#define _TRANSMISSION_H_
#include <map>
namespace Vamos_Body
{
//* A gearbox for the drivetrain.
class Transmission
{
// A map of gears to gear ratios. Neutral has a key of 0.
// Reverse gears have negative keys.
std::map <int, double> m_gear_ratios;
// The number of consecutive forward gears. Any non-consecutive
// gears are inaccessible.
int m_forward_gears;
// The number of consecutive reverse gears. Any non-consecutive
// gears are inaccessible.
int m_reverse_gears;
// The current gear.
int m_gear;
// The rotational speed at the clutch side of the transmission.
double m_clutch_speed;
public:
//** Constructors
// Let the program calulate equally-spaced
Transmission (int forward_gears, double first_ratio, double last_ratio);
Transmission ();
// Shift to a particular gear.
void shift (int gear);
// Set the gear ratio for GEAR. RATIO is (driveshaft speed) /
// (engine speed). Forward gears have positive ratios, usually >
// 1.0. Neutral has a rato of 0.0, unless you change it.
void gear_ratio (int gear, double ratio);
double gear_ratio (int gear) { return m_gear_ratios [gear]; }
// Return the torque on the driveshaft due to friction at the
// clutch.
double torque (double drag);
// Return the current gear.
int gear () const { return m_gear; }
// Return the number of consecutive forward gears.
int forward_gears () const { return m_forward_gears; }
// Return the number of consecutive reverse gears.
int reverse_gears () const { return m_reverse_gears; }
// Tell the transmission what the rotational speed of the
// driveshaft is.
void set_driveshaft_speed (double speed);
// Return the rotational speed at the clutch side of the
// transmission.
double clutch_speed () const { return m_clutch_speed; }
};
}
#endif // not _TRANSMISSION_H_