< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AerialMovement(...)0%110100%
GetDynamicPressure()0%2100%
CalculateDrag()0%56700%
CalculateLiftInducedDrag(...)0%12300%

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 {
 28658  public AerialMovement(IAgent agent) : base(agent) {}
 9
 10  // Calculate the dynamic pressure on the agent.
 011  protected float GetDynamicPressure() {
 012    float airDensity = Constants.CalculateAirDensityAtAltitude(Agent.Position.y);
 013    float flowSpeed = Agent.Speed;
 014    return 0.5f * airDensity * (flowSpeed * flowSpeed);
 015  }
 16
 17  // Calculate the air drag acting on the agent.
 018  protected float CalculateDrag() {
 019    var staticConfig = Agent.StaticConfig;
 020    float dragCoefficient = staticConfig.LiftDragConfig?.DragCoefficient ?? 0;
 021    float crossSectionalArea = staticConfig.BodyConfig?.CrossSectionalArea ?? 0;
 022    float mass = staticConfig.BodyConfig?.Mass ?? 1;
 023    float dynamicPressure = GetDynamicPressure();
 024    float dragForce = dragCoefficient * dynamicPressure * crossSectionalArea;
 025    return dragForce / mass;
 026  }
 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".
 030  protected float CalculateLiftInducedDrag(in Vector3 accelerationInput) {
 031    var staticConfig = Agent.StaticConfig;
 032    float liftAcceleration = Vector3.ProjectOnPlane(accelerationInput, Agent.Forward).magnitude;
 033    float liftDragRatio = staticConfig.LiftDragConfig?.LiftDragRatio ?? 1;
 034    return Mathf.Abs(liftAcceleration / liftDragRatio);
 035  }
 36}