首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用四元数对对象进行RotateAround

使用四元数对对象进行RotateAround
EN

Stack Overflow用户
提问于 2021-06-02 20:06:36
回答 2查看 129关注 0票数 0

我有一个很好的问题要问代码管理员。想一想,你只有一个计算的旋转值来旋转变换。但您必须随子轴心位置旋转。如何解决这个问题?

感谢您的宝贵时间:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-06-03 07:33:12

代码是我写的。以下是解决方案。

票数 1
EN

Stack Overflow用户

发布于 2021-06-11 00:02:22

为什么要重新发明轮子?;)

Unity有Transform.RotateAround,对于输入,您可以简单地使用Quaternion.ToAngleAxis,例如

代码语言:javascript
运行
复制
public static class TransformExtensions
{
    public static void RotateAround(this Transform transform, Transform pivot, Quaternion rotation)
    {  
        RotateAround (transform, pivot.transform.position, rotation);
    } 

    public static void RotateAround(this Transform transform, Vector3 pivotPoint, Quaternion rotation)
    {   
        rotation.ToAngleAxis(out var angle, out var axis);

        transform.RotateAround(pivotPoint, axis, angle);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67804791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档