• 旋转矩阵


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class TestGame : MonoBehaviour
    {
    
        public Vector2 p1;
        public Vector2 p2;
    
        public GameObject go;
    
    
        private void OnGUI()
        {
            if (GUILayout.Button("计算"))
            {
    
                Vector3 right = go.transform.right;
                Vector3 up = go.transform.up;
                Vector3 forward = go.transform.forward;
    
                //把go的轴旋转到 世界方向
                Matrix4x4 rotM = new Matrix4x4();
                rotM.m00 = right.x; rotM.m01 = up.x; rotM.m02 = forward.x; rotM.m03 = 0;
                rotM.m10 = right.y; rotM.m11 = up.y; rotM.m12 = forward.y; rotM.m13 = 0;
                rotM.m20 = right.z; rotM.m21 = up.z; rotM.m22 = forward.z; rotM.m23 = 0;
                rotM.m30 = 0; rotM.m31 = 0; rotM.m32 = 0; rotM.m33 = 1;
    
                Matrix4x4 M = rotM.transpose;
    
                Vector4 right4 = new Vector4(right.x, right.y, right.z, 0);
                Vector4 rightM = M * right4;
                Debug.LogError(rightM);
                //Debug.LogError(rightM.x + "   " + rightM.y + "   " + rightM.z);
                Vector4 up4 = new Vector4(up.x, up.y, up.z,0);
                Vector4 upM = M * up4;
                Debug.LogError(upM);
    
            }
        }
    
    }
    

      

    using System.Collections;using System.Collections.Generic;using UnityEngine;
    public class TestGame : MonoBehaviour{
        public Vector2 p1;    public Vector2 p2;
        public GameObject go;

        private void OnGUI()    {        if (GUILayout.Button("计算"))        {
                Vector3 right = go.transform.right;            Vector3 up = go.transform.up;            Vector3 forward = go.transform.forward;
                //把go的轴旋转到 世界方向            Matrix4x4 rotM = new Matrix4x4();            rotM.m00 = right.x; rotM.m01 = up.x; rotM.m02 = forward.x; rotM.m03 = 0;            rotM.m10 = right.y; rotM.m11 = up.y; rotM.m12 = forward.y; rotM.m13 = 0;            rotM.m20 = right.z; rotM.m21 = up.z; rotM.m22 = forward.z; rotM.m23 = 0;            rotM.m30 = 0; rotM.m31 = 0; rotM.m32 = 0; rotM.m33 = 1;
                Matrix4x4 M = rotM.transpose;
                Vector4 right4 = new Vector4(right.x, right.y, right.z, 0);            Vector4 rightM = M * right4;            Debug.LogError(rightM);            //Debug.LogError(rightM.x + "   " + rightM.y + "   " + rightM.z);            Vector4 up4 = new Vector4(up.x, up.y, up.z,0);            Vector4 upM = M * up4;            Debug.LogError(upM);
            }    }
    }

  • 相关阅读:
    如何改变Activity在当前任务堆栈中的顺序,Intent参数大全
    SQL删除重复记录,并只保留一条
    SpringCloud+Eureka+Feign+Ribbon+zuul的简化搭建流程和CRUD练习
    Spring Cloud Bus 消息总线
    Spring Cloud之Swagger集群搭建
    nginx-ZUUL集群
    spring boot swagger-ui.html 404
    jenkins 部署docker 容器 eureka 集群 完整配置 多台服务器
    Linux(Centos)之安装Nginx及注意事项
    Idea 导出Modules =>jar
  • 原文地址:https://www.cnblogs.com/cocotang/p/13496778.html
Copyright © 2020-2023  润新知