This 2-degree-of-freedom simulation models heave (vertical translation) and pitch (rotation). The PID controller uses the bow sonar measurement to adjust the main-foil flap; as the craft pitches, pitch-rate damping arises from the induced angle of attack (Δα) computed at each foil.
When the sailor tilts the mast into the wind (windward heel), the underwater main foil tilts with it. This is the primary mechanism for steering a straight course. It splits the foil's lift vector into two components:
The Horizontal Balance
For the craft to hold a straight course without lateral drift, the foil side force must balance the sail's leeway force. The simulation enforces this equilibrium: FAero is computed to match the foil side force implied by the selected heel angle (θ):
By calculating the physical Z-coordinate depth of each individual foil, the simulation allows for individual foil ventilation. If the nose pitches up excessively, the forward strut breaches first, dropping Lmain to 0. The still-submerged rudder then produces a large restoring pitching moment that returns the nose downward, reproducing the characteristic recovery behaviour of a hydrofoil after a main-foil breach.
The PID controller uses the bow's height sensor to adjust the main foil flap, seeking vertical equilibrium. The Proportional (P) term reacts instantly to errors, the Integral (I) provides automatic trim against steady loads (such as the sailor's weight), and the Derivative (D) term damps vertical motion, suppressing oscillations.
Unlike simple 1D simulations, this controller operates in a realistic 2-Degree-of-Freedom (Pitch-Heave) space. When the controller deflects the main flap downward, the response is not pure heave; lift increases only at the forward strut, creating a nose-up pitching moment (M). As the nose pitches up, the Angle of Attack (AoA) for the entire hull and rudder foil increases, compounding the lift and introducing complex secondary oscillations.
The simulation calculates the exact real-time Induced Angle of Attack (Δα) caused by the boat's rotation. Because the main foil is ahead of the CG and the rudder is far behind it, pitching nose-up (q > 0) actively pushes the rudder downward into the water column.
This relative downward motion increases the rudder's local angle of attack and hence its lift, producing a nose-down restoring moment. The pitch damping thus emerges directly from the aerodynamic model rather than from an artificial damping term.
Lift is strictly defined as perpendicular to the incoming freestream. Since the boat is traveling predominantly horizontally, the lift vectors are projected directly upwards (relative to the world horizon), independent of the hull's pitch angle. This geometry is accounted for mathematically (Moment = L · x · cos θ) and visually using Canvas context counter-rotations.