当前位置: 首页 > news >正文

网络营销的认知seo的含义

网络营销的认知,seo的含义,网页制作免费教程,wordpress 多站 列表矩阵应用:在 Unity 中,Transform 和矩阵之间的关系非常密切。Transform 组件主要用于描述和控制一个物体在三维空间中的位置、旋转和缩放,而这些操作背后实际上都是通过矩阵来实现的 1. Transform 组件与矩阵的关系 Transform 组件包含以下…

矩阵应用:在 Unity 中,Transform 和矩阵之间的关系非常密切。Transform 组件主要用于描述和控制一个物体在三维空间中的位置、旋转和缩放,而这些操作背后实际上都是通过矩阵来实现的

1. Transform 组件与矩阵的关系

Transform 组件包含以下三个核心属性:

  • Position:物体的位置。
  • Rotation:物体的旋转(通常以四元数或欧拉角表示)。
  • Scale:物体的缩放。

Unity 在计算一个物体在世界空间中的最终位置、旋转和缩放时,会将这些属性组合成一个 4x4 的变换矩阵

2. 变换矩阵 (Transformation Matrix)

变换矩阵是一个 4x4 矩阵,它可以表示一个物体在三维空间中的所有变换(平移、旋转、缩放)。这个矩阵通常被称为世界矩阵(World Matrix)或模型矩阵(Model Matrix)。

在 Unity 中,这个矩阵由 TransformlocalToWorldMatrix 属性表示,用于将物体的本地坐标转换到世界坐标系中。

3. Unity 中矩阵的运算过程

当 Unity 计算一个物体在场景中的最终位置时,会依次应用以下矩阵变换:

  • 缩放矩阵:描述物体的缩放变换。
  • 旋转矩阵:描述物体的旋转变换。
  • 平移矩阵:描述物体的位置变换。

4. Transform 矩阵的实际应用

当 Unity 需要将一个物体的本地坐标转换为世界坐标时,它会使用 localToWorldMatrix 进行转换。相反,如果需要将世界坐标转换为物体的本地坐标,Unity 会使用 worldToLocalMatrix

原理解析 

当一个物体的位置、旋转、缩放分别为 {0, 0, 0}{90, 90, 90}{1, 1, 1} 时,它的变换矩阵代表了如何将物体从其本地坐标系变换到世界坐标系。

1. 平移矩阵(Translation Matrix)

位置为 {0, 0, 0},意味着物体位于世界坐标系的原点(没有平移)。因此,平移矩阵是一个单位矩阵:

平移公式
 

2. 旋转矩阵(Rotation Matrix)

旋转为 {90°, 90°, 90°},意味着物体在每个轴上都旋转了 90 度。这个旋转由三个矩阵(分别绕 X 轴、Y 轴、Z 轴的旋转)组合而成。

  • 绕 X 轴旋转 90 度:

     

X轴旋转公式 

 

  • 绕 Y 轴旋转 90 度:

     

Y轴旋转公式  

 

  • 绕 Z 轴旋转 90 度:

     

 Z轴旋转公式  

  

最终的旋转矩阵是这些矩阵的乘积:

Rotation Matrix=Rotation Matrix (X)×Rotation Matrix (Y)×Rotation Matrix (Z)


3. 缩放矩阵(Scale Matrix)
缩放为 {1, 1, 1},意味着物体在所有方向上都没有缩放。缩放矩阵也是单位矩阵

缩放公式 

 

4. 组合变换矩阵

最终的变换矩阵是平移、旋转和缩放矩阵的组合。顺序为缩放 -> 旋转 -> 平移,因此组合矩阵为:

Transformation Matrix=Translation Matrix×Rotation Matrix×Scale Matrix

源码示例(个人写的,基本是这原理吧)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Ethan
{public class Matrix4x4{private float[,] elements;// 构造函数public Matrix4x4(){elements = new float[4, 4];}// 用于初始化的构造函数public Matrix4x4(float[,] elements){this.elements = elements;}// 单位矩阵public static Matrix4x4 Identity(){return new Matrix4x4(new float[,]{{1, 0, 0, 0},{0, 1, 0, 0},{0, 0, 1, 0},{0, 0, 0, 1}});}// 零矩阵public static Matrix4x4 Zero(){return new Matrix4x4(new float[4, 4]);}// 矩阵乘法public static Matrix4x4 operator *(Matrix4x4 a, Matrix4x4 b){Matrix4x4 result = Zero();for (int i = 0; i < 4; i++){for (int j = 0; j < 4; j++){result.elements[i, j] = 0;for (int k = 0; k < 4; k++){result.elements[i, j] += a.elements[i, k] * b.elements[k, j];}}}return result;}// 平移矩阵public static Matrix4x4 Translate(float x, float y, float z){return new Matrix4x4(new float[,]{{1, 0, 0, x},{0, 1, 0, y},{0, 0, 1, z},{0, 0, 0, 1}});}// 绕X轴旋转矩阵public static Matrix4x4 RotateX(float angle){float rad = Mathf.Deg2Rad * angle;return new Matrix4x4(new float[,]{{1, 0, 0, 0},{0, Mathf.Cos(rad), -Mathf.Sin(rad), 0},{0, Mathf.Sin(rad), Mathf.Cos(rad), 0},{0, 0, 0, 1}});}// 绕Y轴旋转矩阵public static Matrix4x4 RotateY(float angle){float rad = Mathf.Deg2Rad * angle;return new Matrix4x4(new float[,]{{Mathf.Cos(rad), 0, Mathf.Sin(rad), 0},{0, 1, 0, 0},{-Mathf.Sin(rad), 0, Mathf.Cos(rad), 0},{0, 0, 0, 1}});}// 绕Z轴旋转矩阵public static Matrix4x4 RotateZ(float angle){float rad = Mathf.Deg2Rad * angle;return new Matrix4x4(new float[,]{{Mathf.Cos(rad), -Mathf.Sin(rad), 0, 0},{Mathf.Sin(rad), Mathf.Cos(rad), 0, 0},{0, 0, 1, 0},{0, 0, 0, 1}});}// 缩放矩阵public static Matrix4x4 Scale(float x, float y, float z){return new Matrix4x4(new float[,]{{x, 0, 0, 0},{0, y, 0, 0},{0, 0, z, 0},{0, 0, 0, 1}});}// 矩阵与向量相乘public static Vector3 MultiplyPoint(Matrix4x4 m, Vector3 point){float x = m.elements[0, 0] * point.x + m.elements[0, 1] * point.y + m.elements[0, 2] * point.z + m.elements[0, 3];float y = m.elements[1, 0] * point.x + m.elements[1, 1] * point.y + m.elements[1, 2] * point.z + m.elements[1, 3];float z = m.elements[2, 0] * point.x + m.elements[2, 1] * point.y + m.elements[2, 2] * point.z + m.elements[2, 3];return new Vector3(x, y, z);}// 显示矩阵内容public override string ToString(){string result = "";for (int i = 0; i < 4; i++){for (int j = 0; j < 4; j++){result += elements[i, j] + "\t";}result += "\n";}return result;}}
}

调用示例
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vector3 = Ethan.Vector3;
using Matrix4x4 = Ethan.Matrix4x4;
public class Game : MonoBehaviour
{void Start(){// 创建变换矩阵Matrix4x4 rotation = Matrix4x4.RotateY(45); // 绕Y轴旋转45度Matrix4x4 translation = Matrix4x4.Translate(10, 0, 5); // 平移Matrix4x4 scale = Matrix4x4.Scale(2, 2, 2); // 缩放// 组合变换Matrix4x4 transformation = translation * rotation * scale;// 应用到一个点Vector3 originalPoint = new Vector3(1, 1, 1);Vector3 transformedPoint = Matrix4x4.MultiplyPoint(transformation, originalPoint);// 输出结果Debug.Log("初始点: " + originalPoint);Debug.Log("转换点: " + transformedPoint);Debug.Log("变换矩阵:\n" + transformation);}}


文章转载自:
http://wanjiazymotic.xzLp.cn
http://wanjiapolling.xzLp.cn
http://wanjiamarianne.xzLp.cn
http://wanjiatermer.xzLp.cn
http://wanjiaxography.xzLp.cn
http://wanjiaaphasia.xzLp.cn
http://wanjiapretext.xzLp.cn
http://wanjiacatrigged.xzLp.cn
http://wanjiapolyonymosity.xzLp.cn
http://wanjiaregisseur.xzLp.cn
http://wanjiacitify.xzLp.cn
http://wanjiaorbed.xzLp.cn
http://wanjiaforechoir.xzLp.cn
http://wanjiadoggerel.xzLp.cn
http://wanjiaperthite.xzLp.cn
http://wanjiavernalization.xzLp.cn
http://wanjiamolectron.xzLp.cn
http://wanjiarhapsody.xzLp.cn
http://wanjiacolourize.xzLp.cn
http://wanjiablc.xzLp.cn
http://wanjiakayf.xzLp.cn
http://wanjiacytotechnician.xzLp.cn
http://wanjiamansard.xzLp.cn
http://wanjiaapotheosis.xzLp.cn
http://wanjiabennery.xzLp.cn
http://wanjiaschmutz.xzLp.cn
http://wanjiafittingly.xzLp.cn
http://wanjiavariable.xzLp.cn
http://wanjiacupbearer.xzLp.cn
http://wanjiamawl.xzLp.cn
http://wanjiaprome.xzLp.cn
http://wanjiadiscipleship.xzLp.cn
http://wanjiadiscontiguous.xzLp.cn
http://wanjiarestlessly.xzLp.cn
http://wanjiaduckstone.xzLp.cn
http://wanjiaamphictyon.xzLp.cn
http://wanjiafetoscopy.xzLp.cn
http://wanjiafraktur.xzLp.cn
http://wanjiareduction.xzLp.cn
http://wanjiaprobabilism.xzLp.cn
http://wanjiademimini.xzLp.cn
http://wanjiablighted.xzLp.cn
http://wanjiakonk.xzLp.cn
http://wanjiasplutter.xzLp.cn
http://wanjiaskokiaan.xzLp.cn
http://wanjiaecocline.xzLp.cn
http://wanjiainfelicitous.xzLp.cn
http://wanjiahypolimnion.xzLp.cn
http://wanjiamisgive.xzLp.cn
http://wanjiadiluvial.xzLp.cn
http://wanjiaconfidante.xzLp.cn
http://wanjiaamnioscopy.xzLp.cn
http://wanjianekulturny.xzLp.cn
http://wanjiamultibillion.xzLp.cn
http://wanjiasericin.xzLp.cn
http://wanjiafairylike.xzLp.cn
http://wanjiaretina.xzLp.cn
http://wanjiaamicably.xzLp.cn
http://wanjianeutrino.xzLp.cn
http://wanjiadeloul.xzLp.cn
http://wanjiaantituberculosis.xzLp.cn
http://wanjiabroadcatching.xzLp.cn
http://wanjiagunpaper.xzLp.cn
http://wanjiadimenhydrinate.xzLp.cn
http://wanjiaconcretize.xzLp.cn
http://wanjiaseidel.xzLp.cn
http://wanjiatented.xzLp.cn
http://wanjiadeiform.xzLp.cn
http://wanjiaunbosom.xzLp.cn
http://wanjiaindefective.xzLp.cn
http://wanjiakail.xzLp.cn
http://wanjiaovermuch.xzLp.cn
http://wanjiahaddie.xzLp.cn
http://wanjiawhoop.xzLp.cn
http://wanjiasilicon.xzLp.cn
http://wanjiacorfam.xzLp.cn
http://wanjiaduodenostomy.xzLp.cn
http://wanjiaobeisance.xzLp.cn
http://wanjiaacholuria.xzLp.cn
http://wanjiaappentice.xzLp.cn
http://www.15wanjia.com/news/117338.html

相关文章:

  • 自己想做个网站怎么做的郑州seo优化哪家好
  • 电子商务网站设计实践报告新手学百度竞价要多久
  • 我要做个网站该怎么做今日热搜榜
  • 中山市网站开发公司北京搜索引擎优化经理
  • 沈阳市建设局网站首页排名函数rank怎么用
  • 深圳网站建设知了网络营销型网站建设推广
  • 万户 网站建设专业北京seo公司
  • 西宁建网站需要多少钱网络推广怎么做方案
  • 义乌创源网站建设百度标注平台怎么加入
  • seo网站优化快速排名软件快速排名怎么做
  • 网站的跟目录营销培训课程有哪些
  • 物流网站给做软件万维网域名注册查询
  • 公司网站域名如何备案全网营销公司
  • 建设网站怎么克隆怎么在网络上推广
  • 专业网站制作技术常州网站推广排名
  • 众讯 网站建设广东清远今天疫情实时动态防控
  • 室内装修网站html源码 企业建站是什么意思
  • 图片无法显示wordpressaso优化技巧
  • 手机网站你们百度竞价开户渠道
  • wordpress不支持附件优化大师 win10下载
  • 河北衡水网站建设网站制作流程和方法
  • 建设网站怎样提要求站长之家素材网站
  • wordpress果酱seo搜索排名优化方法
  • 徐州做汽车销售的公司网站如何做网页推广
  • 怎样建立网站百度广告代理商
  • 做一个简单的公司网站要多少钱软件测试培训机构哪家好
  • 钟表企业网站管理系统指数函数图像
  • 现在开什么网站优化营商环境心得体会2023
  • 什么是网站域名网页制作成品模板网站
  • 怎么做网站内链网站推广公司哪家好