// Runs after all GameObjects have been created in a room. It will complete the creation of all tracks, including their calculated fields. private void BuildTrackCalculations() { // Loop through every track. foreach (var trackMatch in this.tracks) { Track track = trackMatch.Value; // Identify Destination Track (if applicable). if (track.toId != 0) { // If unavailable, nullify this track's behavior. if (!this.tracks.ContainsKey(track.toId)) { track.toId = 0; continue; } Track destTrack = this.tracks[track.toId]; // Calculate distance, rotation, and speed of the track's movement. track.distance = TrigCalc.GetDistance(track.posX, track.posY, destTrack.posX, destTrack.posY); track.rotation = Radians.GetRadiansBetweenCoords(track.posX, track.posY, destTrack.posX, destTrack.posY); track.speed = FInt.Create((float)(track.distance / track.duration)); } } }
// Reverse / Invert Radians public static float Reverse(float radian) { return(Radians.Normalize(radian + (float)Math.PI)); }
// Conversions public static float ConvertToPercent(float degrees) { return(Spectrum.GetPercentFromValue(Radians.Wrap(degrees), -180f, 180f)); }
public static float ConvertToPercent(float radian) { return(Spectrum.GetPercentFromValue(Radians.Wrap(radian), (0 - (float)Math.PI), (float)Math.PI)); }
public static float GetYFromRotation(float degrees, float distance) { return(Radians.GetYFromRotation(Degrees.ConvertToRadians(degrees), distance)); }