Skip to content

A3D_EulerToQuaternion

imshooter edited this page Oct 17, 2026 · 1 revision

Turn the rotation of an object into a quaternion, in the order of GetVehicleRotationQuat.

native bool:A3D_EulerToQuaternion(
    Float:rx,
    Float:ry,
    Float:rz,
    &Float:w,
    &Float:x,
    &Float:y,
    &Float:z
);

Parameters

Parameter Description
Float:rx Rotation on the X axis.
Float:ry Rotation on the Y axis.
Float:rz Rotation on the Z axis.
&Float:w Real part of the quaternion.
&Float:x Part of the X axis.
&Float:y Part of the Y axis.
&Float:z Part of the Z axis.

Returns

  • true when the quaternion was written.

Remarks

The angles are those of SetObjectRot. The quaternion is the one GetVehicleRotationQuat would give for a vehicle turned the same way, in the same order: w first, then x, y and z. ColAndreas writes w last, so swap the order when porting.

Example

Tells whether a vehicle stands turned like an object, slopes included.

stock bool:IsTurnedLike(vehicleid, Float:rx, Float:ry, Float:rz) {
    new
        Float:w,
        Float:x,
        Float:y,
        Float:z,
        Float:vehicleW,
        Float:vehicleX,
        Float:vehicleY,
        Float:vehicleZ
    ;

    A3D_EulerToQuaternion(rx, ry, rz, w, x, y, z);
    GetVehicleRotationQuat(vehicleid, vehicleW, vehicleX, vehicleY, vehicleZ);

    return floatabs(w * vehicleW + x * vehicleX + y * vehicleY + z * vehicleZ) > 0.99;
}

Related

  • A3D_QuaternionToEuler: Turn a quaternion, such as one from GetVehicleRotationQuat, into the rotation of an object.
  • A3D_GetRotation: The rotation of a physics object, as an object rotation.

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally