From 965d4d401271e19754796aad0421aa2135d68518 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Thu, 11 Jun 2009 21:14:34 +0100 Subject: [PATCH] Rename the displaced curve function --- include/TrackCommon.hpp | 4 ++-- src/Points.cpp | 4 ++-- src/TrackCommon.cpp | 23 ++++++----------------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/include/TrackCommon.hpp b/include/TrackCommon.hpp index e7d7b9c..26cfda1 100644 --- a/include/TrackCommon.hpp +++ b/include/TrackCommon.hpp @@ -28,8 +28,8 @@ void renderReflectedHypTanRail(); void renderCurvedTrack(int baseRadius, track::Angle startAngle, track::Angle endAngle); void transformToOrigin(int baseRadius, track::Angle startAngle); -float hypTanCurveFunc(float x); -float reflectedHypTanCurveFunc(float x); +float displacedCurveFunc(float x); +float reflectedDisplacedCurveFunc(float x); // Track constants namespace track { diff --git a/src/Points.cpp b/src/Points.cpp index 6cfeb47..b0ad562 100644 --- a/src/Points.cpp +++ b/src/Points.cpp @@ -182,11 +182,11 @@ void Points::transform(const track::TravelToken& aToken, double aDelta) const const float curveDelta = aDelta * 3.0f / len; const float fValue = 3.0f - curveDelta; - const float curveValue = hypTanCurveFunc(fValue); + const float curveValue = displacedCurveFunc(fValue); // Calculate the angle that the tangent to the curve at this // point makes to (one of) the axis at this point - const float grad = approxGradient(hypTanCurveFunc, fValue); + const float grad = approxGradient(displacedCurveFunc, fValue); const float angle = radToDeg(atanf(grad)); if (myAxis == -axis::X && aToken.direction == axis::X) { diff --git a/src/TrackCommon.cpp b/src/TrackCommon.cpp index a205476..eae173f 100644 --- a/src/TrackCommon.cpp +++ b/src/TrackCommon.cpp @@ -261,26 +261,15 @@ namespace { } // The function that determines the curve of points and S-bends -float hypTanCurveFunc(float x) +float displacedCurveFunc(float x) { - const float linearAbove = 2.7f; - const float wantOneAt = 2.9f; - if (x <= linearAbove) - // Use the curvey function - return 0.5f * (1.0f + tanh(1.8f * x - 3.5f)); - else { - // Interpolate linearly - const float fLinearAbove = hypTanCurveFunc(linearAbove); - const float m = (1.0f - fLinearAbove) / (wantOneAt - linearAbove); - - return m*(x - linearAbove) + fLinearAbove; - } + return 0.5f * (1.0f + tanh(1.8f * x - 3.5f)); } // The above function reflected about the x-axis -float reflectedHypTanCurveFunc(float x) +float reflectedDisplacedCurveFunc(float x) { - return -hypTanCurveFunc(x); + return -displacedCurveFunc(x); } // Draw a sleeper in the current maxtrix location @@ -308,7 +297,7 @@ void renderStraightRail() void renderHypTanRail() { if (!theHypTanRailMesh) - theHypTanRailMesh = generateFuncRailMesh(hypTanCurveFunc); + theHypTanRailMesh = generateFuncRailMesh(displacedCurveFunc); glPushMatrix(); @@ -325,7 +314,7 @@ void renderReflectedHypTanRail() { if (!theReflectedHypTanRailMesh) theReflectedHypTanRailMesh = - generateFuncRailMesh(reflectedHypTanCurveFunc); + generateFuncRailMesh(reflectedDisplacedCurveFunc); glPushMatrix(); -- 2.39.2