四元素与点的乘法-得到的是空间点做旋转后的点的坐标-AR开发常用

本文介绍了一个用于计算四元数旋转矢量的函数SCNVector3QuaternionMultVector。该函数通过复杂的数学运算实现了三维空间中矢量点绕指定轴的旋转,常应用于3D图形处理和游戏开发中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SCNVector3 QuaternionMultVector(SCNQuaternion rotation, SCNVector3 point)
{
    float num = rotation.x * 2;
    float num2 = rotation.y * 2;
    float num3 = rotation.z * 2;
    float num4 = rotation.x * num;
    float num5 = rotation.y * num2;
    float num6 = rotation.z * num3;
    float num7 = rotation.x * num2;
    float num8 = rotation.x * num3;
    float num9 = rotation.y * num3;
    float num10 = rotation.w * num;
    float num11 = rotation.w * num2;
    float num12 = rotation.w * num3;
    SCNVector3 result;
    result.x = (1 - (num5 + num6)) * point.x + (num7 - num12) * point.y + (num8 + num11) * point.z;
    result.y = (num7 + num12) * point.x + (1 - (num4 + num6)) * point.y + (num9 - num10) * point.z;
    result.z = (num8 - num11) * point.x + (num9 + num10) * point.y + (1 - (num4 + num5)) * point.z;
    return result;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值