# yawing moment due to rudder in F-16 model
import numpy as np


def dndr(alpha, beta):
    A = np.asarray([[-.018, -.052, -.052, -.052, -.054, -.049, -.059, -.051, -.030, -.037, -.026, -.013],
                    [-.028, -.051, -.043, -.046, -.045, -.049, -.057, -.052, -.030, -.033, -.030, -.008],
                    [-.037, -.041, -.038, -.040, -.040, -.038, -.037, -.030, -.027, -.024, -.019, -.013],
                    [-.048, -.045, -.045, -.045, -.044, -.045, -.047, -.048, -.049, -.045, -.033, -.016],
                    [-.043, -.044, -.041, -.041, -.040, -.038, -.034, -.035, -.035, -.029, -.022, -.009],
                    [-.052, -.034, -.036, -.036, -.035, -.028, -.024, -.023, -.020, -.016, -.010, -.014],
                    [-.062, -.034, -.027, -.028, -.027, -.027, -.023, -.023, -.019, -.009, -.025, -.010]])
    A = np.transpose(A)
    row = 2
    col = 3

    s = 0.2 * alpha
    k = np.fix(s)
    if k <= -2:
        k = -1

    if k >= 9:
        k = 8

    da = s - k
    l = k + np.fix(np.sign(da) * 1.1)

    if l < -2:
        l = -2
    elif l > 9:
        l = 9

    s = 0.1 * beta
    m = np.fix(s)
    if m <= -3:
        m = -2

    if m >= 3:
        m = 2

    db = s - m
    n = m + np.fix(np.sign(db) * 1.1)

    if n < -3:
        n = -3
    elif n > 3:
        n = 3

    t = A[int(k) + row, int(m) + col]
    u = A[int(k) + row, int(n) + col]
    v = t + abs(da) * (A[int(l) + row, int(m) + col] - t)
    w = u + abs(da) * (A[int(l) + row, int(n) + col] - u)
    dndr_value = v + (w - v) * abs(db)
    return dndr_value

# yawing moment due to rudder in F-16 model
import numpy as np


def dndr(alpha, beta):
    A = np.asarray([[-.018, -.052, -.052, -.052, -.054, -.049, -.059, -.051, -.030, -.037, -.026, -.013],
                    [-.028, -.051, -.043, -.046, -.045, -.049, -.057, -.052, -.030, -.033, -.030, -.008],
                    [-.037, -.041, -.038, -.040, -.040, -.038, -.037, -.030, -.027, -.024, -.019, -.013],
                    [-.048, -.045, -.045, -.045, -.044, -.045, -.047, -.048, -.049, -.045, -.033, -.016],
                    [-.043, -.044, -.041, -.041, -.040, -.038, -.034, -.035, -.035, -.029, -.022, -.009],
                    [-.052, -.034, -.036, -.036, -.035, -.028, -.024, -.023, -.020, -.016, -.010, -.014],
                    [-.062, -.034, -.027, -.028, -.027, -.027, -.023, -.023, -.019, -.009, -.025, -.010]])
    A = np.transpose(A)
    row = 2
    col = 3

    s = 0.2 * alpha
    k = np.fix(s)
    if k <= -2:
        k = -1

    if k >= 9:
        k = 8

    da = s - k
    l = k + np.fix(np.sign(da) * 1.1)

    if l < -2:
        l = -2
    elif l > 9:
        l = 9

    s = 0.1 * beta
    m = np.fix(s)
    if m <= -3:
        m = -2

    if m >= 3:
        m = 2

    db = s - m
    n = m + np.fix(np.sign(db) * 1.1)

    if n < -3:
        n = -3
    elif n > 3:
        n = 3

    t = A[int(k) + row, int(m) + col]
    u = A[int(k) + row, int(n) + col]
    v = t + abs(da) * (A[int(l) + row, int(m) + col] - t)
    w = u + abs(da) * (A[int(l) + row, int(n) + col] - u)
    dndr_value = v + (w - v) * abs(db)
    return dndr_value

# yawing moment due to rudder in F-16 model