Editor/Geometry/ArchApproachAxes.cs

Editor utility for approach geometry. Computes outward and across unit vectors from an approach yaw, and returns width/half-width values accounting for spline node scaling and a minimum of 12 units.

Reflection
using System;
using Sandbox;

namespace Sunless.Architecture;

// The frame an approach stands in, read off its own yaw and width. A crossover meets a drive at the kerb and the
// tool draws its handles, neither of which resolves a ramp or a flight, so this is core geometry over the payload.
public static class ArchApproachAxes
{
	public static Vector2 Outward( ArchApproachPart approach )
	{
		var radians = approach.Yaw.DegreeToRadian();

		return new Vector2( MathF.Cos( radians ), MathF.Sin( radians ) );
	}

	public static Vector2 Across( ArchApproachPart approach )
	{
		var outward = Outward( approach );

		return new Vector2( -outward.y, outward.x );
	}

	public static float WidthAt( ArchApproachPart approach, int index )
	{
		if ( !approach.IsSpline || index < 0 || index >= approach.Nodes.Count )
		{
			return MathF.Max( 12f, approach.Width );
		}

		return MathF.Max( 12f, approach.Width * MathF.Max( 0.01f, approach.Nodes[index].WidthScale ) );
	}

	public static float HalfWidth( ArchApproachPart approach ) => WidthAt( approach, 0 ) * 0.5f;
}