It only gets half the arc, when tested here with a BeamAPI's .getTo(). But there are some other wrinkles I found when I was testing all of this out.
I'm also having some real problems with didDamageThisFrame() with WeaponAPIs that are isBurstBeam, which is returning true even when the Beam is not, actually, in contact with the shield that frame.
This code, on the other hand, is pretty much good:
public static boolean isWithinShieldArc(ShipAPI ship, Vector2f point)
{
Vector2f shipLoc = ship.getLocation();
float shieldRange = ship.getShield().getRadius() + 45f;
if(MathUtils.getDistanceSquared(shipLoc, point) > shieldRange * shieldRange) return false;
float shieldAngle = ship.getShield().getFacing();
float shieldArc = ship.getShield().getArc() / 2f;
// Check if weapon is aimed at any part of the target
Vector2f endArcLeft = MathUtils.getPointOnCircumference(shipLoc, shieldRange, shieldAngle - shieldArc);
Vector2f endArcRight = MathUtils.getPointOnCircumference(shipLoc, shieldRange, shieldAngle + shieldArc);
float radSquared = shieldRange * shieldRange;
boolean partiallyInArc = (Line2D
.ptSegDistSq(
shipLoc.x,
shipLoc.y,
endArcLeft.x,
endArcLeft.y,
point.x,
point.y) <= radSquared)
|| (Line2D
.ptSegDistSq(
shipLoc.x,
shipLoc.y,
endArcRight.x,
endArcRight.y,
point.x,
point.y) <= radSquared);
return partiallyInArc;
}
Note the fudge-factor 45f in the distance check; it's necessary for isBurstBeam weapons, as they don't appear to be following the rest of the rules; the actual getTo() Vector2f is not actually in contact with the Shield, but can be some distance away, yet it's doing damage that frame. I'm guessing that has to do with burst-beams needing a little help under the hood to deal with their beam-speeds, etc., but it produced some unexpected behaviors here.