local maf = require 'maf' local vec3 = maf.vec3 local quat = maf.quat local ffi =…
- User
local maf = require 'maf' local vec3 = maf.vec3 local quat = maf.quat
local ffi = require 'ffi'
-- Define the structures based on usual usage patterns ffi.cdef[[ typedef struct { float x, y, z, w; } RtQuat;
typedef struct { float x, y, z; } RwV3d;]]
-- Declare the functions local BoneNode_c_QuatToEuler = ffi.cast('void (__cdecl*)(RtQuat*, RwV3d*)', 0x617080) local BoneNode_c_EulerToQuat = ffi.cast('void (__cdecl*)(RwV3d*, RtQuat*)', 0x6171F0)
function QuatToEuler(qx, qy, qz, qw) local quat = ffi.new('RtQuat', {qx, qy, qz, qw}) local angles = ffi.new('RwV3d') BoneNode_c_QuatToEuler(quat, angles) return angles.x, angles.y, angles.z end
function EulerToQuat(ax, ay, az) local angles = ffi.new('RwV3d', {ax, ay, az}) local quat = ffi.new('RtQuat') BoneNode_c_EulerToQuat(angles, quat) return quat.x, quat.y, quat.z, quat.w end
function main() if not isSampLoaded() or not isSampfuncsLoaded() then return end while not isSampAvailable() do wait(0) end
while true do local car = storeCarCharIsInNoSave(playerPed) local qx, qy, qz, qw = getVehicleQuaternion(car) local ex, ey, ez = QuatToEuler(qx, qy, qz, qw) local positionX, positionY, positionZ = getCarCoordinates(car) local directionVector = vec3(0, -10, 1) positionX, positionY, positionZ = (vec3(positionX, positionY, positionZ) + (quat(qx, qy, qz, qw) * directionVector)):unpack() local cameraOffset = vec3(0, 100, 0) local camX, camY, camZ = (vec3(positionX, positionY, positionZ) + (quat(qx, qy, qz, qw) * cameraOffset)):unpack() attachCameraToVehicle(car, 0, -10, 1, 0, 0, 0, ey, 2) wait(0) endend
этот код правильно считает крен самолета(ey) приблизительно до 70 градусов. после достижения ~70 градусов ey начинает уменьшаться обратно, вместо того чтобы расти дальше.
как я могу добиться правильного рассчета крена?
- Assistant
- User
я не могу поменять функцию QuatToEuler но наверное я могу повернуть кватернион, прежде чем подавать его в эту функцию? повернуть так, чтобы поменялся порядок углов эйлера
- Assistant
- User
нет... я не имел ввиду просто повернуть кватернион, я говорил про то, чтобы повернуть его так, чтобы одна ось эйлера - стала другой осью эйлера
- Assistant
- User
а если короткое название из 1-2-3 слов? вроде того же moonadditions
- Assistant
When choosing a short name for your project that involves mathematical operations with vectors, quaternions, and possibly game development related to transformations, you'll want something memorable, descriptive, and perhaps with a bit of flair. Here are several suggestions that could suit your project:
- QuatShift - Highlights the quaternion manipulation aspect and the idea of shifting or transforming rotations.
- EulerSwap - Emphasizes the swapping of Euler angles, reflecting your technique of manipulating basis configurations.
- AxisTune - Suggests fine-tuning of axes during transformations, which could connect well with your problem-solving approach.
- Rotax - A blend of "rotation" and "axis," implying manipulation of rotational axes.
- SpinMorph - Implies morphing of rotational data through spins, quite fitting for quaternion manipulations.