PulleyBeltHelper
A static class in Root.Township, the global namespace.
Static maths helper that works out the path of a belt or rope wrapped around a loop of pulleys (circles), used by Belt and BeltVisual.
- Listed in Global namespace: P
- Nested types
BeltOutput,Circle
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private static List<PulleyBeltHelper.Circle> circles | Working copies of the input circles with the offset added. |
private static List<ICircle> exterior | Circles found to be wrapped on the outside during the last GetRope. |
private static Vector3 firstDirection | Start direction on the first circle, used to close the loop. |
private static Vector3 firstPosition | Start point on the first circle, used to close the loop. |
private static bool firstSide | Whether the belt starts on the outside of the first circle. |
private static float maximumSegmentLength | Longest straight segment allowed before Cut splits it. |
private static Vector3 nextDirection | Direction carried between recursive steps to draw each pulley's arc. |
private static Dictionary<int, List<PulleyBeltHelper.BeltOutput>> outputs | Valid tangent options per circle index, filled by EvaluateOptions. |
private static float segmentsPerDegree | Arc points per degree of wrap around a pulley. |
Methods
| Member | What it is |
|---|---|
static IEnumerable<ICircle> GetExterior(IList<ICircle> input, float offset) | Returns the input circles the belt wraps around on their outside. |
static IEnumerable<Vector3> GetRope(IList<ICircle> input, float segmentsPerDegree, float maximumSegmentLength, float offset) (iterator) | Yields the points of a closed belt around the given circles, with radii grown by offset and long segments split. |
8 private and internal methods
| Member | What it is |
|---|---|
private static IEnumerable<Vector3> AttemptCircle(int current, bool side, bool nextSide) (iterator) | Recursive step that tries each tangent option on a circle and yields the belt points if the loop closes back to the first circle. |
private static IEnumerable<Vector3> Cut(Vector3 from, Vector3 to) (iterator) | Yields extra points between two points so no segment is longer than maximumSegmentLength. |
private static IEnumerable<Vector3> DrawCurve(Vector3 lastDirection, Vector3 direction, Vector3 center, float radius) (iterator) | Yields the points of the arc the belt follows around one pulley. |
private static void EvaluateOptions(int index, ICircle a, ICircle b, ICircle c) | Works out which inner and outer tangent lines from one circle to the next are valid, given the circle after it, and stores them in outputs. |
private static void EvaluateOptions(int index, ICircle a, ICircle b, ICircle c, Vector3 forward, bool isSameSide, bool isExternal, out bool isValid1, out bool isValid2) | Works out which inner and outer tangent lines from one circle to the next are valid, given the circle after it, and stores them in outputs. |
private static bool GetTangent(Vector3 pointA, Vector3 pointB, Vector3 face, float radius, out Vector3 tangentLine1) | Finds a tangent line between two circle centres for a given working radius. Returns false if the circles overlap too much. |
private static IEnumerable<Vector3> GetUncutResults() (iterator) | Yields the belt points before long segments are split, starting from circle 0. |
private static float GetWorkingRadius(ICircle a, ICircle b, bool isNonCrossing) | Difference of two radii for a non-crossing tangent, or their sum for a crossing one. |