forked from Koenvh1/ts-map
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTsRoadLook.cs
38 lines (31 loc) · 1.03 KB
/
TsRoadLook.cs
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
using System;
using System.Collections.Generic;
using TsMap.Common;
namespace TsMap
{
public class TsRoadLook
{
public ulong Token { get; }
public float Offset;
public readonly List<string> LanesLeft;
public readonly List<string> LanesRight;
public static double Hermite(float s, float x, float z, double tanX, double tanZ)
{
double h1 = 2 * Math.Pow(s, 3) - 3 * Math.Pow(s, 2) + 1;
double h2 = -2 * Math.Pow(s, 3) + 3 * Math.Pow(s, 2);
double h3 = Math.Pow(s, 3) - 2 * Math.Pow(s, 2) + s;
double h4 = Math.Pow(s, 3) - Math.Pow(s, 2);
return h1 * x + h2 * z + h3 * tanX + h4 * tanZ;
}
public TsRoadLook(ulong token)
{
LanesLeft = new List<string>();
LanesRight = new List<string>();
Token = token;
}
public float GetWidth()
{
return Offset + Consts.LaneWidth * LanesLeft.Count + Consts.LaneWidth * LanesRight.Count;
}
}
}