Unity3D学习笔记(三十三):矩阵
-
-
- a b c d f
g h i j k k
k

1x- + -2x4, 1x7 + -2x1/
5x- + 0x4, 5x7 + 0x1/ 3x- + -1x0 + 4x3, 3x0 + -1x7 + 4x-, 3x3 + -1x- + 4x2, 2x2 + 3x5 +4x3, 2x3 + 3x7 +4x4, 2x1 + 3x2 +4x5
2x2 + 7x5 +10x3, 2x3 + 7x7 +10x4, 2x1 + 7x2 +10x5
三阶方阵的行列式的计算:

2x2x8+ 3x5x1 + 7x3x3
-2x5x3 - 3x3x8 - 7x2x1 2x5 - 3x4
矩阵 C11 =(4x2 - 3x1 ) x (-)(+)
C12 =(3x2 - 5x1 ) x (-)(+)
C13 =(3x3 - 5x4 ) x (-)(+)
C21 =(4x2 - 3x5 ) x (-)(+)
C22 =(2x2 - 5x5 ) x (-)(+)
C23 =(2x3 - 5x4 ) x (-)(+)
C31 =(4x1 - 4x5 ) x (-)(+)
C32 =(2x1 - 3x5 ) x (-)(+)
C33 =(2x4 - 3x4 ) x (-)(+) - -
-
- - -
矩阵 矩阵的行列式
|M| = - = - 标准伴随矩阵
-
- 转置矩阵
-
- 逆矩阵
-/ /
/ -/
矩阵 矩阵的行列式
|M| = ++ --- = - 标准伴随矩阵
-
-
- 转置矩阵
-
-
- 逆矩阵
-/ /
/ -/ -/
-/ -/ /
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateMesh : MonoBehaviour
{
void Start () { MeshFilter mf = gameObject.AddComponent<MeshFilter>();
MeshRenderer mr = gameObject.AddComponent<MeshRenderer>(); //先实例化一个网格
Mesh mesh = new Mesh(); //确定网格的四个顶点
//先创建一个Vector3类型的数组
Vector3[] vertexs = new Vector3[];
vertexs[] = new Vector3(-, , );
vertexs[] = new Vector3(, , );
vertexs[] = new Vector3(-, -, );
vertexs[] = new Vector3(, -, ); //把顶点给mesh
mesh.vertices = vertexs; //再确定顶点组成三角面的顺序,注意数组的数量一定是3的倍数
//因为3个顶点才能组成1个三角面,注意三角面的顶点的顺序,顺时针在正面,逆时针在反面
int[] triangles = new int[] {,,,,,};
mesh.triangles = triangles; //最终把网格给MeshFilter
mf.mesh = mesh;
}
}

using UnityEngine;
using System.Collections;
public class buildMesh : MonoBehaviour { public Vector3 vertLeftTopFront = new Vector3(-,,);
public Vector3 vertRightTopFront = new Vector3(,,);
public Vector3 vertRightTopBack = new Vector3(,,-);
public Vector3 vertLeftTopBack = new Vector3(-,,-);
private float waitN = 3f;
private float waitD = 3f;
public int shapeN = ; void Start ()
{
MeshFilter mf = GetComponent<MeshFilter>();
Mesh mesh = mf.mesh; //Vertices//
Vector3[] vertices = new Vector3[]
{
//front face//
vertLeftTopFront,//left top front, 0
vertRightTopFront,//right top front, 1
new Vector3(-,-,),//left bottom front, 2
new Vector3(,-,),//right bottom front, 3
//back face//
vertRightTopBack,//right top back, 4
vertLeftTopBack,//left top back, 5
new Vector3(,-,-),//right bottom back, 6
new Vector3(-,-,-),//left bottom back, 7
//left face//
vertLeftTopBack,//left top back, 8
vertLeftTopFront,//left top front, 9
new Vector3(-,-,-),//left bottom back, 10
new Vector3(-,-,),//left bottom front, 11
//right face//
vertRightTopFront,//right top front, 12
vertRightTopBack,//right top back, 13
new Vector3(,-,),//right bottom front, 14
new Vector3(,-,-),//right bottom back, 15
//top face//
vertLeftTopBack,//left top back, 16
vertRightTopBack,//right top back, 17
vertLeftTopFront,//left top front, 18
vertRightTopFront,//right top front, 19
//bottom face//
new Vector3(-,-,),//left bottom front, 20
new Vector3(,-,),//right bottom front, 21
new Vector3(-,-,-),//left bottom back, 22
new Vector3(,-,-)//right bottom back, 23
}; //Triangles// 3 points, clockwise determines which side is visible
int[] triangles = new int[]
{
//front face//
,,,//first triangle
,,,//second triangle
//back face//
,,,//first triangle
,,,//second triangle
//left face//
,,,//first triangle
,,,//second triangle
//right face//
,,,//first triangle
,,,//second triangle
//top face//
,,,//first triangle
,,,//second triangle
//bottom face//
,,,//first triangle
,,//second triangle
}; //UVs//
Vector2[] uvs = new Vector2[]
{
//front face// 0,0 is bottom left, 1,1 is top right//
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,),
new Vector2(,)
}; mesh.Clear ();
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uvs;
;
mesh.RecalculateNormals(); } void Update ()
{
if(waitN > 0f)
{
waitN -= Time.deltaTime;
}
else
{
waitN = waitD;
shapeN ++;
if(shapeN > )
{
shapeN = ;
}
}
//morph to cube//
if(shapeN == )
{
vertLeftTopFront = Vector3.Lerp(vertLeftTopFront, new Vector3(-,,),Time.deltaTime);
vertRightTopFront = Vector3.Lerp(vertRightTopFront, new Vector3(,,),Time.deltaTime);
vertRightTopBack = Vector3.Lerp(vertRightTopBack, new Vector3(,,-),Time.deltaTime);
vertLeftTopBack = Vector3.Lerp(vertLeftTopBack, new Vector3(-,,-),Time.deltaTime);
}
//morph to pyramid//
if(shapeN == )
{
vertLeftTopFront = Vector3.Lerp(vertLeftTopFront, new Vector3(,,),Time.deltaTime);
vertRightTopFront = Vector3.Lerp(vertRightTopFront, new Vector3(,,),Time.deltaTime);
vertRightTopBack = Vector3.Lerp(vertRightTopBack, new Vector3(,,),Time.deltaTime);
vertLeftTopBack = Vector3.Lerp(vertLeftTopBack, new Vector3(,,),Time.deltaTime);
}
//morph to ramp//
if(shapeN == )
{
vertLeftTopFront = Vector3.Lerp(vertLeftTopFront, new Vector3(-,-,),Time.deltaTime);
vertRightTopFront = Vector3.Lerp(vertRightTopFront, new Vector3(,-,),Time.deltaTime);
vertRightTopBack = Vector3.Lerp(vertRightTopBack, new Vector3(,0.5f,-),Time.deltaTime);
vertLeftTopBack = Vector3.Lerp(vertLeftTopBack, new Vector3(-,0.5f,-),Time.deltaTime);
}
//morph to roof//
if(shapeN == )
{
vertLeftTopFront = Vector3.Lerp(vertLeftTopFront, new Vector3(-,0.2f,),Time.deltaTime);
vertRightTopFront = Vector3.Lerp(vertRightTopFront, new Vector3(,0.2f,),Time.deltaTime);
vertRightTopBack = Vector3.Lerp(vertRightTopBack, new Vector3(,0.2f,),Time.deltaTime);
vertLeftTopBack = Vector3.Lerp(vertLeftTopBack, new Vector3(-,0.2f,),Time.deltaTime);
}
Start();
}
}
Unity3D学习笔记(三十三):矩阵的更多相关文章
- Unity3D学习笔记(十三):委托、考试复习
委托:比较什么时候用委托好 下课案例:不用下课铃 1.ClassManager需要拿到所有教室的引用,课堂管理者应该只负责计时并告知每间教室 2.每间教室应该是由当班老师负责是否需要下课,而课堂管 ...
- PHP学习笔记三十三【自定义错误处理器】
<?php //自定义错误处理器 //$errorno 错误号 //$errmes错误信息 //这两个参数是必须的 function my_error($errorno,$errmes) { e ...
- 【Unity 3D】学习笔记三十三:游戏元素——天空盒子
天空盒子 一般的3D游戏都会有着北京百年一遇的蓝天.让人惊叹不已.事实上天空这个效果没有什么神奇的仅仅需用到天空盒子这个组件即可.能够将天空设想成一个巨大的盒子,这个盒子将整个游戏视图和全部的游戏元素 ...
- Unity3D学习笔记3——Unity Shader的初步使用
目录 1. 概述 2. 详论 2.1. 创建材质 2.2. 着色器 2.2.1. 名称 2.2.2. 属性 2.2.3. SubShader 2.2.3.1. 标签(Tags) 2.2.3.2. 渲染 ...
- VSTO 学习笔记(十三)谈谈VSTO项目的部署
原文:VSTO 学习笔记(十三)谈谈VSTO项目的部署 一般客户计算机专业水平不高,但是有一些Office水平相当了得,尤其对Excel的操作非常熟练.因此如果能将产品的一些功能集成在Office中, ...
- Unity3D学习笔记2——绘制一个带纹理的面
目录 1. 概述 2. 详论 2.1. 网格(Mesh) 2.1.1. 顶点 2.1.2. 顶点索引 2.2. 材质(Material) 2.2.1. 创建材质 2.2.2. 使用材质 2.3. 光照 ...
- Unity3D学习笔记6——GPU实例化(1)
目录 1. 概述 2. 详论 3. 参考 1. 概述 在之前的文章中说到,一种材质对应一次绘制调用的指令.即使是这种情况,两个三维物体使用同一种材质,但它们使用的材质参数不一样,那么最终仍然会造成两次 ...
- Unity3D学习笔记7——GPU实例化(2)
目录 1. 概述 2. 详论 2.1. 实现 2.2. 解析 3. 参考 1. 概述 在上一篇文章<Unity3D学习笔记6--GPU实例化(1)>详细介绍了Unity3d中GPU实例化的 ...
- Unity3D学习笔记8——GPU实例化(3)
目录 1. 概述 2. 详论 2.1. 自动实例化 2.2. MaterialPropertyBlock 3. 参考 1. 概述 在前两篇文章<Unity3D学习笔记6--GPU实例化(1)&g ...
- Oracle学习笔记三 SQL命令
SQL简介 SQL 支持下列类别的命令: 1.数据定义语言(DDL) 2.数据操纵语言(DML) 3.事务控制语言(TCL) 4.数据控制语言(DCL)
随机推荐
- codeforces 975C Valhalla Siege
题意: 有n个巫师站成一列,每个巫师有自己的血量. 一个人射箭攻击他们,每次造成若干点伤害,巫师按照给定的顺序承受伤害,如果伤害大了,那么死掉,伤害落到下一个巫师身上. 如果一轮攻击之后,所有的巫师都 ...
- arc 093 C – Traveling Plan
题意: 给出横坐标上一系列的点,一个人从0出发按照下标顺序访问每一个点,再回到0点. 问每次如果去掉一个点,那么访问的距离变为多少. 思路: 去掉这个点,那么就减去这个点到上一点到这一点的距离,减去这 ...
- 使用IntelljIDEA生成接口的类继承图及装饰器模式
类图生成方法 以一个装饰器模式实现数学运算的例子为例. 安装 Intellj Ultimate , lience server: http://xdouble.cn:8888/ 在类上右键点击 cla ...
- 转:Http下载文件类 支技断点续传功能
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net ...
- crontab 在指定时间范围每隔2小时执行一次和指定时间执行实例
crontab 在指定时间范围每隔2小时执行一次和指定时间执行,下面实例实现了:10-23点每两个小时执行一次,2点执行一次,分钟依次是1 2 3 ,没有24点的,晚上12点是0点注:*代表所有的取值 ...
- json.dumps(),json.loads(),json.dump(),json.load()方法的区别
1. json.dumps() json.dump()是将字典类型转化成字符串类型. import json dic = {'a':'1111','b':'2222','c':'3333','d':' ...
- Install kubernetes without yum
下载最新版本: https://github.com/kubernetes/kubernetes/releases 下载kubernetes.tar.gz即可 解压缩后到cluster目录下 执行ge ...
- 在MyEclipse中使用javadocAPI文档
开始啦 1.打开MyEclipse,选中要导出的项目,右击Exprot弹出窗口,选择java----javadoc点击next到下一界面. 2.选出要导出的项目或要添加的项目,在browse中选择路径 ...
- Linux环境jdk的安装
1.下载jdk1.7,oracle的下载地址已经失效,找了个其他的地址进行下载. wget http://pc.xzstatic.com/2017/03/jdk7u79linuxx64.tar.gz ...
- JavaScript笔记 #06# Promise简单例子
索引 回调版本 Promise版本1 Promise版本2 Notes 参考资料: Promise JavaScript Promise:简介 你去书店借书,按照异步的套路,剧情如下↓ 你:“老板,有 ...