Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    Class SailController

    Manages sail physics by calculating and applying lift and drag forces based on sail geometry, orientation, and wind conditions. Uses four corner transforms (a, b, c, d) to define sail shape, enabling dynamic sail configurations including furling and multi-part sails. Calculates apparent wind from true wind and vessel velocity, then applies aerodynamic forces at the sail's surface-weighted center. The corner transforms follow a clockwise pattern: a (bottom left/front), b (top left/front), c (top right/rear), d (bottom right/rear). Corner transforms can be attached to different parents to enable sail furling or complex rigging systems. Use SailRotator for user-controlled sail rotation. Requires a WindGenerator in the scene and a SailPreset for aerodynamic coefficients.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SailController
    Namespace: NWH.DWP2.SailController
    Assembly: NWH.DWP2.dll
    Syntax
    public class SailController : MonoBehaviour

    Fields

    | Edit this page View Source

    a

    Bottom left corner of the sail for square sails, or bottom front corner for triangular sails. First point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.

    Declaration
    [Tooltip("Bottom left sail corner if square sail.\r\nOtherwise bottom front.")]
    public Transform a
    Field Value
    Type Description
    Transform
    | Edit this page View Source

    airDensity

    Air density in kg/m³ used in aerodynamic force calculations. Standard sea level value is 1.225 kg/m³. Can be adjusted as a multiplier to scale all sail forces uniformly without modifying the preset.

    Declaration
    [Tooltip("The air density. Can also be used\r\nas a force coefficient as this affects both lift and drag forces equally.")]
    public float airDensity
    Field Value
    Type Description
    float
    | Edit this page View Source

    b

    Top left corner of the sail for square sails, or top front corner for triangular sails. Second point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.

    Declaration
    [Tooltip("Top left sail corner if square sail.\r\nOtherwise top front.")]
    public Transform b
    Field Value
    Type Description
    Transform
    | Edit this page View Source

    c

    Top right corner of the sail for square sails, or top rear corner for triangular sails. Third point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.

    Declaration
    [Tooltip("Top right sail corner if square sail.\r\nOtherwise top rear.")]
    public Transform c
    Field Value
    Type Description
    Transform
    | Edit this page View Source

    d

    Bottom right corner of the sail for square sails, or bottom rear corner for triangular sails. Fourth point in the clockwise corner definition pattern. Can be attached to any parent transform to enable dynamic sail configurations.

    Declaration
    [Tooltip("Bottom right sail corner if square sail.\r\nOtherwise bottom rear.")]
    public Transform d
    Field Value
    Type Description
    Transform
    | Edit this page View Source

    sailPreset

    Defines the aerodynamic characteristics of the sail through lift and drag coefficient curves. Contains the relationship between angle of attack and force coefficients.

    Declaration
    public SailPreset sailPreset
    Field Value
    Type Description
    SailPreset

    Properties

    | Edit this page View Source

    AngleOfAttack

    Angle in degrees between the sail's forward direction and the apparent wind direction. Measured on the horizontal plane using Vector3.up as the reference axis. Used to determine lift and drag coefficients from the SailPreset curves. Positive values indicate wind from the starboard side, negative values from port side.

    Declaration
    public float AngleOfAttack { get; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    ApparentWind

    Wind experienced by the sail relative to the moving vessel. Calculated as the vector difference between true wind and vessel velocity. This is the effective wind that generates aerodynamic forces on the sail. Measured in meters per second.

    Declaration
    public Vector3 ApparentWind { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    SailArea

    Total surface area of the sail in square meters. Calculated from the quadrilateral formed by corner points a, b, c, and d. Used in aerodynamic force calculations along with dynamic pressure.

    Declaration
    public float SailArea { get; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    SailCenter

    Surface-weighted center point of the sail in world space. All aerodynamic forces are applied at this position. Calculated from the quadrilateral formed by corner points a, b, c, and d.

    Declaration
    public Vector3 SailCenter { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    SailForce

    Total aerodynamic force vector applied to the vessel at the sail center point. Combines lift and drag forces based on sail geometry, apparent wind, and aerodynamic coefficients. Measured in Newtons.

    Declaration
    public Vector3 SailForce { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    SailForward

    Forward direction vector of the sail in world space. Determined by the vector from corner point d to corner point a. Used to calculate the angle of attack relative to the apparent wind.

    Declaration
    public Vector3 SailForward { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    SailRight

    Right direction vector of the sail in world space. Derived from the cross product of SailUp and SailForward. Defines the direction of lift force generation perpendicular to the sail plane.

    Declaration
    public Vector3 SailRight { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    SailUp

    Up direction vector of the sail in world space. Calculated from the average of the top edge to the average of the bottom edge. Used to determine sail orientation and compensate for heel angle.

    Declaration
    public Vector3 SailUp { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    ShipVelocity

    Current velocity of the vessel's Rigidbody in world space. Used to calculate apparent wind by combining with true wind. Measured in meters per second.

    Declaration
    public Vector3 ShipVelocity { get; }
    Property Value
    Type Description
    Vector3
    | Edit this page View Source

    TrueWind

    True wind vector from the WindGenerator, representing the actual environmental wind. Does not account for vessel motion. Measured in meters per second.

    Declaration
    public Vector3 TrueWind { get; }
    Property Value
    Type Description
    Vector3
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics