local socket = require "socket" local maf = require "maf" local vec3, quat = maf.vec3,…
- User
local socket = require "socket" local maf = require "maf" local vec3, quat = maf.vec3, maf.quat local samem = require "SAMemory"
samem.require "CVehicle" samem.require "tHandlingData" samem.require "CPlane" samem.require 'CTransmission'
-- Constants for controlling plane steering behavior local PITCH_UP_THRESHOLD = -15 -- Pitch angle threshold in degrees local FINE_STEERING_ANGLE = 15 -- Angle for fine-steering adjustments in degrees local YAW_FACTOR = 1 -- Multiplicative factor for yaw adjustment local ROLL_FACTOR = 0.75 -- Multiplicative factor for roll adjustment local STEERING_SPEED = 25.0 -- Speed of steering control in units per second
-- Direction vectors local DIRECTION = { FORWARD = vec3(0, 1, 0), BACKWARD = vec3(0, -1, 0), RIGHT = vec3(1, 0, 0), LEFT = vec3(-1, 0, 0), UP = vec3(0, 0, 1), DOWN = vec3(0, 0, -1) }
function math.sign(x) if x > 0 then return 1 elseif x < 0 then return -1 else return 0 end end
-- Calculate the signed angle between two vectors with respect to a reference axis local function calculateSignedAngle(from, to, axis) local fromNormalized, toNormalized = from:clone():normalize(), to:clone():normalize() local dotProduct = fromNormalized:dot(toNormalized) local angle = math.acos(math.max(-1, math.min(1, dotProduct))) -- Clamp the dot product local crossProduct = fromNormalized:cross(toNormalized) local sign = crossProduct:dot(axis) < 0 and -1 or 1 return angle * sign end
-- Calculate the angle between two vectors in degrees local function calculateAngleBetweenVectors(v1, v2) local normV1, normV2 = v1:normalize(), v2:normalize() local dotProduct = math.max(-1, math.min(1, normV1:dot(normV2))) -- Clamp the dot product return math.deg(math.acos(dotProduct)) end
-- Obtain the conjugate of a quaternion local function conjugateQuaternion(q) return quat(-q.x, -q.y, -q.z, q.w) end
-- Smooth step function local function smoothstep(edge0, edge1, x) x = math.max(0, math.min(1, (x - edge0) / (edge1 - edge0))) return x * x * (3 - 2 * x) end
local function dxDrawRing(posX, posY, radius, width, startAngle, amount, color, absoluteAmount, anglesPerLine) if type(posX) ~= "number" or type(posY) ~= "number" or type(startAngle) ~= "number" or type(amount) ~= "number" then print("Error: One of the required parameters (posX, posY, startAngle, amount) is not a number.") return false end
radius = type(radius) == "number" and radius or 50 width = type(width) == "number" and width or 5 color = color or 0xFFFFFFFF absoluteAmount = type(absoluteAmount) == "boolean" and absoluteAmount or false anglesPerLine = type(anglesPerLine) == "number" and anglesPerLine or 1 local stopAngle = absoluteAmount and (amount + startAngle) or ((amount * 360) + startAngle) for angle = startAngle, stopAngle, anglesPerLine do local radAngle = math.rad(angle) local startX = math.cos(radAngle) * (radius - width) local startY = math.sin(radAngle) * (radius - width) local endX = math.cos(radAngle) * (radius + width) local endY = math.sin(radAngle) * (radius + width) renderDrawLine(startX + posX, startY + posY, endX + posX, endY + posY, width, color) end return math.floor((stopAngle - startAngle) / anglesPerLine) - Assistant