TORCS  1.3.9
The Open Racing Car Simulator
trackutil.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : trackutil.cpp
4  created : Sun Jan 30 22:58:00 CET 2000
5  copyright : (C) 2000 by Eric Espie
6  email : torcs@free.fr
7  version : $Id$
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #include <stdlib.h>
21 #include <math.h>
22 
23 #include <tgf.h>
24 #include <track.h>
25 
26 #include <robottools.h>
27 
28 void
30 {
32 }
33 
34 
35 void
37 {
38  RtTrackGlobal2Local(segment, X, Y, p, type);
39 }
40 /*
41  * Function
42  *
43  *
44  * Description
45  *
46  *
47  * Parameters
48  *
49  *
50  * Return
51  *
52  */
53 
54 tdble
56 {
57  return RtTrackHeightL(p);
58 }
59 
60 tdble
62 {
63  return RtTrackHeightG(seg, x, y);
64 }
65 
66 void
67 TrackSideNormal(tTrackSeg *seg, tdble x, tdble y, int side, t3Dd *norm)
68 {
69  RtTrackSideNormalG(seg, x, y, side, norm);
70 }
71 
72 void
74 {
75  RtTrackSurfaceNormalL(p, norm);
76 }
77 
78 tdble
79 TrackSpline(tdble p0, tdble p1, tdble t0, tdble t1, tdble t)
80 {
81  tdble t2, t3;
82  tdble h0, h1, h2, h3;
83 
84  t2 = t * t;
85  t3 = t * t2;
86  h1 = 3 * t2 - 2 * t3;
87  h0 = 1 - h1;
88  h2 = t3 - 2 * t2 + t;
89  h3 = t3 - t2;
90 
91  return h0 * p0 + h1 * p1 + h2 * t0 + h3 * t1;
92 }
tdble RtTrackHeightL(tTrkLocPos *p)
Returns the absolute height in meters of the road at the Local position p.
Definition: rttrack.cpp:314
tdble RtTrackHeightG(tTrackSeg *seg, tdble X, tdble Y)
Returns the absolute height in meters of the road at the Global position (segment, X, Y)
Definition: rttrack.cpp:443
Location on the track in local coordinates.
Definition: track.h:418
void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag)
Calculate global coordinates from a local position relative to the given track segment (segment...
Definition: rttrack.cpp:80
void TrackGlobal2Local(tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
Definition: trackutil.cpp:36
Robots Tools.
tdble TrackHeightG(tTrackSeg *seg, tdble x, tdble y)
Definition: trackutil.cpp:61
Definition: Basic.h:58
void TrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y)
Definition: trackutil.cpp:29
void RtTrackGlobal2Local(tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
Convert a Global (segment, X, Y) position into a Local one (segment, toRight, toStart)The segment in ...
Definition: rttrack.cpp:156
void RtTrackSideNormalG(tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
Give the normal vector of the border of the track including the sides.
Definition: rttrack.cpp:470
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
static Point p[4]
Definition: Convex.cpp:54
The Gaming Framework API.
Definition: Basic.h:58
void TrackSurfaceNormal(tTrkLocPos *p, t3Dd *norm)
Definition: trackutil.cpp:73
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
Definition: track.h:276
static Vector y[4]
Definition: Convex.cpp:56
tdble TrackSpline(tdble p0, tdble p1, tdble t0, tdble t1, tdble t)
Definition: trackutil.cpp:79
#define TR_TORIGHT
Definition: track.h:413
3D point.
Definition: tgf.h:115
Track Structure and Track Loader Module Definition.
void RtTrackSurfaceNormalL(tTrkLocPos *p, t3Dd *norm)
Used to get the normal vector of the road (pointing upward).
Definition: rttrack.cpp:540
tdble TrackHeightL(tTrkLocPos *p)
Definition: trackutil.cpp:55
void TrackSideNormal(tTrackSeg *seg, tdble x, tdble y, int side, t3Dd *norm)
Definition: trackutil.cpp:67