]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/FGGround.cpp
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / YASim / FGGround.cpp
1 #ifdef HAVE_CONFIG_H
2   #include <config.h>
3 #endif
4
5 #include <FDM/flight.hxx>
6
7 #include "Glue.hpp"
8 #include "Ground.hpp"
9
10 #include "FGGround.hpp"
11 namespace yasim {
12
13 FGGround::FGGround(FGInterface *iface) : _iface(iface)
14 {
15     _toff = 0.0;
16 }
17
18 FGGround::~FGGround()
19 {
20 }
21
22 void FGGround::getGroundPlane(const double pos[3],
23                               double plane[4], float vel[3])
24 {
25     // Return values for the callback.
26     double loadCapacity, frictionFactor, agl;
27     double cp[3], dvel[3];
28     int type;
29     _iface->get_agl_m(_toff, pos, cp, plane, dvel,
30                       &type, &loadCapacity, &frictionFactor, &agl);
31
32     // The plane below the actual contact point.
33     plane[3] = plane[0]*cp[0] + plane[1]*cp[1] + plane[2]*cp[2];
34
35     for(int i=0; i<3; i++) vel[i] = dvel[i];
36 }
37
38 void FGGround::getGroundPlane(const double pos[3],
39                               double plane[4], float vel[3],
40                               int *type, const SGMaterial **material
41                               )
42 {
43     // Return values for the callback.
44     double agl;
45     double cp[3], dvel[3];
46     _iface->get_agl_m(_toff, pos, cp, plane, dvel,
47                       type, material, &agl);
48
49     // The plane below the actual contact point.
50     plane[3] = plane[0]*cp[0] + plane[1]*cp[1] + plane[2]*cp[2];
51
52     for(int i=0; i<3; i++) vel[i] = dvel[i];
53 }
54
55 bool FGGround::caughtWire(const double pos[4][3])
56 {
57     return _iface->caught_wire_m(_toff, pos);
58 }
59
60 bool FGGround::getWire(double end[2][3], float vel[2][3])
61 {
62     double dvel[2][3];
63     bool ret = _iface->get_wire_ends_m(_toff, end, dvel);
64     for (int i=0; i<2; ++i)
65       for (int j=0; j<3; ++j)
66         vel[i][j] = dvel[i][j];
67     return ret;
68 }
69
70 void FGGround::releaseWire(void)
71 {
72     _iface->release_wire();
73 }
74
75 float FGGround::getCatapult(const double pos[3], double end[2][3],
76                             float vel[2][3])
77 {
78     double dvel[2][3];
79     float dist = _iface->get_cat_m(_toff, pos, end, dvel);
80     for (int i=0; i<2; ++i)
81       for (int j=0; j<3; ++j)
82         vel[i][j] = dvel[i][j];
83     return dist;
84 }
85
86 void FGGround::setTimeOffset(double toff)
87 {
88     _toff = toff;
89 }
90
91
92 }; // namespace yasim
93