Matrix4x4类
来源:互联网 发布:周易古代注本知乎 编辑:程序博客网 时间:2024/06/06 05:34
MultiplyPoint3x4 矩阵变换
public Vector3 MultiplyPoint3x4(Vector3 v);
通过指定的矩阵来变换向量v
下面的代码是通过矩阵m来变换v
void Start () { Matrix4x4 m = Matrix4x4.identity; Vector3 v = Vector3.one; Vector3 v2 = m.MultiplyPoint3x4(v); }
MultiplyVector 矩阵变换
public Vector3 MultiplyVector(Vector3 v);
通过指定的矩阵来变换向量v,只改变向量的方向SetTRS 重设Matrix4*4矩阵
public void SetTRS(Vector3 pos, Quaternion q, Vector3 s);
功能:用来重设Matrix4*4矩阵
参数:pos 位置向量 q 旋转角度
s 缩放向量
我们可以这么写代码
Matrix4x4 m1 = Matrix4x4.identity;
m1.SetTRS(pos, q, s);
Vector3 v2 = m1.MultiplyPoint3x4(v1);
例子:
下面看看如何把向量v1沿y轴增加5个单位,绕y轴旋转45度,缩放2倍
代码:
public class SetTRS : MonoBehaviour{ // Use this for initialization Vector3 v1 = Vector3.one; Vector3 v2 = Vector3.zero; void Start() { Matrix4x4 m1 = Matrix4x4.identity; //Position沿y轴增加5个单位,绕y轴旋转45度,缩放2倍 m1.SetTRS(Vector3.up * 5, Quaternion.Euler(Vector3.up * 45.0f), Vector3.one * 2.0f); //也可以使用如下静态方法设置m1变换 //m1=Matrix4x4.TRS(Vector3.up * 5, Quaternion.Euler(Vector3.up * 45.0f),Vector3.one*2.0f); v2 = m1.MultiplyPoint3x4(v1); } void FixedUpdate() { Debug.DrawLine(Vector3.zero, v1, Color.green); Debug.DrawLine(Vector3.zero, v2, Color.red); }}
其中绿色线是v1,红色线是v1沿y轴增加5个单位,绕y轴旋转45度,缩放2倍的效果
0 0
- Matrix4x4类
- Matrix4x4
- Matrix4x4
- Matrix4x4.MultiplyVector 变换方向
- OpenGL - Matrix4X4 矩阵变换
- OpenGL - Matrix4X4 矩阵变换
- Unity3d-旋转Quaternion、Matrix4x4、 Euler
- 【转】Unity3D开发之Matrix4x4矩阵变换
- Unity3D开发之Matrix4x4矩阵变换
- Unity3D开发之Matrix4x4矩阵变换
- Unity3D开发之Matrix4x4矩阵变换
- unity中的利用Matrix4x4实现平移
- unity中的利用Matrix4x4实现缩放
- Unity3d--GUI自适应矩阵(通过Matrix4x4.SetTRS)
- 类
- 类
- 类
- 类
- 如何为Apache JMeter开发插件(四)——几种类型的Sampler
- innerHTML,innerText,outerHTML用法及区别
- IOS TableView的Cell高度自适应,UILabel自动换行适应(转载)
- 摄像头图像桶形畸变校正测试
- AAC帧格式及编码介绍
- Matrix4x4类
- Xilinx hw_server Program FPGA failed
- Android Multimedia框架总结(四)MediaPlayer中从Java层到C++层类关系及prepare及之后其他过程
- java例题学习:面向对象之长方形例题学习
- 《GPU高性能编程CUDA实战》学习笔记(一)
- 在背景为灰色的PGM图片中,提取地图。
- Spring MVC 项目中配置log4j 出现错误log4j:ERROR Failed to excute sql com.mysql.jdbc.exceptions.jdbc4.MySQLSynt
- 编程,已知字符串:“this is a test of java”.
- QT开发学习资料(3)