TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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
28void
33
34
35void
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
59
62{
63 return RtTrackHeightG(seg, x, y);
64}
65
66void
67TrackSideNormal(tTrackSeg *seg, tdble x, tdble y, int side, t3Dd *norm)
68{
69 RtTrackSideNormalG(seg, x, y, side, norm);
70}
71
72void
77
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}
@ Y
Definition Basic.h:58
@ X
Definition Basic.h:58
static Point p[4]
Definition Convex.cpp:54
static Vector y[4]
Definition Convex.cpp:56
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
struct trackSeg tTrackSeg
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
void RtTrackGlobal2Local(tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
Convert global coordinates to a local track position.
Definition rttrack.cpp:298
tdble RtTrackHeightL(tTrkLocPos *p)
Returns the absolute height in meters of the road at the Local position p.
Definition rttrack.cpp:365
tdble RtTrackHeightG(tTrackSeg *seg, tdble X, tdble Y)
Returns the absolute height in meters of the road at the Global position (segment,...
Definition rttrack.cpp:465
void RtTrackSurfaceNormalL(tTrkLocPos *p, t3Dd *norm)
Used to get the normal vector of the road (pointing upward).
Definition rttrack.cpp:567
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:81
void RtTrackSideNormalG(tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
Compute the horizontal inward border normal using the supplied segment.
Definition rttrack.cpp:495
3D point.
Definition tgf.h:114
Location on the track in local coordinates.
Definition track.h:434
#define TR_TORIGHT
Definition track.h:428
void TrackSurfaceNormal(tTrkLocPos *p, t3Dd *norm)
Definition trackutil.cpp:73
void TrackGlobal2Local(tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
Definition trackutil.cpp:36
tdble TrackSpline(tdble p0, tdble p1, tdble t0, tdble t1, tdble t)
Definition trackutil.cpp:79
void TrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y)
Definition trackutil.cpp:29
void TrackSideNormal(tTrackSeg *seg, tdble x, tdble y, int side, t3Dd *norm)
Definition trackutil.cpp:67
tdble TrackHeightL(tTrkLocPos *p)
Definition trackutil.cpp:55
tdble TrackHeightG(tTrackSeg *seg, tdble x, tdble y)
Definition trackutil.cpp:61