< Summary

Class:LaunchAnglePlannerBase
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Algorithms/Planning/LaunchAnglePlannerBase.cs
Covered lines:12
Uncovered lines:0
Coverable lines:12
Total lines:30
Line coverage:100% (12 of 12)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:5
Method coverage:100% (5 of 5)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LaunchAnglePlannerBase(...)0%110100%
Plan(...)0%110100%
ConvertToRelativeDirection(...)0%110100%

File(s)

/github/workspace/Assets/Scripts/Algorithms/Planning/LaunchAnglePlannerBase.cs

#LineLine coverage
 1using UnityEngine;
 2
 3// Base implementation of a launch angle planner.
 4public abstract class LaunchAnglePlannerBase : ILaunchAnglePlanner {
 915  public IAgent Agent { get; init; }
 6
 427  public LaunchAnglePlannerBase(IAgent agent) {
 218    Agent = agent;
 219  }
 10
 11  // Calculate the optimal launch angle in degrees and the time-to-target in seconds.
 12  public abstract LaunchAngleOutput Plan(in LaunchAngleInput input);
 1113  public LaunchAngleOutput Plan(in Vector3 targetPosition) {
 1114    Direction direction = ConvertToRelativeDirection(targetPosition);
 1115    return Plan(
 16        new LaunchAngleInput { Distance = direction.Distance, Altitude = direction.Altitude });
 1117  }
 18
 19  // Return the absolute intercept position given the absolute target position.
 20  public abstract Vector3 InterceptPosition(in Vector3 targetPosition);
 21
 22  // Convert from a 3D vector to a 2D direction that ignores the azimuth and that is relative to the
 23  // agent's position.
 2924  protected Direction ConvertToRelativeDirection(in Vector3 position) {
 2925    Vector3 relativePosition = position - Agent.Position;
 2926    return new Direction { Distance =
 27                               Vector3.ProjectOnPlane(relativePosition, Vector3.up).magnitude,
 28                           Altitude = Vector3.Project(relativePosition, Vector3.up).y };
 2929  }
 30}