< Summary

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

Metrics

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

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 {
 145  public IAgent Agent { get; init; }
 6
 287  public LaunchAnglePlannerBase(IAgent agent) {
 148    Agent = agent;
 149  }
 10
 11  // Calculate the optimal launch angle in degrees and the time-to-target in seconds.
 12  public abstract LaunchAngleOutput Plan(in LaunchAngleInput input);
 013  public LaunchAngleOutput Plan(in Vector3 targetPosition) {
 014    Direction direction = ConvertToRelativeDirection(targetPosition);
 015    return Plan(
 16        new LaunchAngleInput { Distance = direction.Distance, Altitude = direction.Altitude });
 017  }
 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.
 024  protected Direction ConvertToRelativeDirection(in Vector3 position) {
 025    Vector3 relativePosition = position - Agent.Position;
 026    return new Direction { Distance =
 27                               Vector3.ProjectOnPlane(relativePosition, Vector3.up).magnitude,
 28                           Altitude = Vector3.Project(relativePosition, Vector3.up).y };
 029  }
 30}