< Summary

Class:AerialMovement
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Movements/AerialMovement.cs
Covered lines:21
Uncovered lines:0
Coverable lines:21
Total lines:36
Line coverage:100% (21 of 21)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AerialMovement(...)0%110100%
GetDynamicPressure()0%110100%
CalculateDrag()0%770100%
CalculateLiftInducedDrag(...)0%330100%

File(s)

/github/workspace/Assets/Scripts/Movements/AerialMovement.cs

#LineLine coverage
 1using UnityEngine;
 2
 3// Aerial movement.
 4//
 5// Interceptors and threats have different movements since threats are not affected by drag and
 6// gravity and have specified attack behaviors.
 7public abstract class AerialMovement : MovementBase {
 458  public AerialMovement(IAgent agent) : base(agent) {}
 9
 10  // Calculate the dynamic pressure on the agent.
 1011  protected float GetDynamicPressure() {
 1012    float airDensity = Constants.CalculateAirDensityAtAltitude(Agent.Position.y);
 1013    float flowSpeed = Agent.Speed;
 1014    return 0.5f * airDensity * (flowSpeed * flowSpeed);
 1015  }
 16
 17  // Calculate the air drag acting on the agent.
 1018  protected float CalculateDrag() {
 1019    var staticConfig = Agent.StaticConfig;
 1020    float dragCoefficient = staticConfig.LiftDragConfig?.DragCoefficient ?? 0;
 1021    float crossSectionalArea = staticConfig.BodyConfig?.CrossSectionalArea ?? 0;
 1022    float mass = staticConfig.BodyConfig?.Mass ?? 1;
 1023    float dynamicPressure = GetDynamicPressure();
 1024    float dragForce = dragCoefficient * dynamicPressure * crossSectionalArea;
 1025    return dragForce / mass;
 1026  }
 27
 28  // Calculate the lift-induced drag acting on the agent. Since the agent is flying, any
 29  // acceleration normal to the velocity vector is considered "lift".
 1030  protected float CalculateLiftInducedDrag(in Vector3 accelerationInput) {
 1031    var staticConfig = Agent.StaticConfig;
 1032    float liftAcceleration = Vector3.ProjectOnPlane(accelerationInput, Agent.Forward).magnitude;
 1033    float liftDragRatio = staticConfig.LiftDragConfig?.LiftDragRatio ?? 1;
 1034    return Mathf.Abs(liftAcceleration / liftDragRatio);
 1035  }
 36}