Matrix

  通常像下面这样定义Matrix:

int1x1    iMatrix;   // integer matrix with 1 row,  1 column
int4x1 iMatrix; // integer matrix with 4 rows, 1 column
int1x4 iMatrix; // integer matrix with 1 row, 4 columns
double3x3 dMatrix; // double matrix with 3 rows, 3 columns float2x2 fMatrix = { 0.0f, 0.1, // row 1
2.1f, 2.2f // row 2
};

  也可以像下面这样定义Matrix:

matrix <Type, Number> VariableName
matrix <float, , > fMatrix = { 0.0f, 0.1, // row 1
2.1f, 2.2f // row 2
};

  Member access for matrix types

_m00, _m01,_m02, _m03 

_m10, _m11,_m12, _m13 

_m20, _m21,_m22, _m23 

_m30, _m31,_m32, _m33 

or

_11, _12,_13, _14 

_21, _22,_23, _24 

_31, _32,_33, _34 

_41, _42,_43, _4

参考:http://msdn.microsoft.com/en-us/library/windows/desktop/bb509623(v=vs.85).aspx

Vector

  通常像下面这样定义Vector:

bool    bVector;   // scalar containing 1 Boolean
int1 iVector = ;
float3 fVector = { 0.2f, 0.3f, 0.4f };

  也可像下面这样定义:

vector <Type, Number> VariableName

vector <int,    > iVector = ;
vector <double, > dVector = { 0.2, 0.3, 0.4, 0.5 };

Scalar

  • bool - true or false.
  • int - 32-bit signed integer.
  • uint - 32-bit unsigned integer.
  • dword - 32-bit unsigned integer.
  • half - 16-bit floating point value. This data type is provided only for language compatibility. Direct3D 10 shader targets map all half data types to float data types. A half data type cannot be used on a uniform global variable (use the /Gec flag if this functionality is desired).
  • float - 32-bit floating point value.
  • double - 64-bit floating point value. You cannot use double precision values as inputs and outputs for a stream. To pass double precision values between shaders, declare each double as a pair of uint data types. Then, use the asdouble function to pack each double into the pair of uints and the asuint function to unpack the pair of uints back into the double.

Per-Component Math Operations

  可以单独取出Vector中的分量进行计算:

float4 pos = float4(,,,);
float2 f_2D;
f_2D = pos.xy; // read two components
f_2D = pos.xz; // read components in any order
f_2D = pos.zx; f_2D = pos.xx; // components can be read more than once
f_2D = pos.yy;

  读取matrix的某一行:

float2 temp;
float2x2 fMatrix;
temp = fMatrix[] // read the first row

参考:http://msdn.microsoft.com/en-us/library/windows/desktop/bb509634(v=vs.85).aspx

CG中的类型的更多相关文章

  1. CG中的数据变量类型

    CG 中的数据变量类型有三: float:高精度浮点值,通常是32位. half:中精度浮点值.通常是16位,范围是-60000至+60000,它适合存储UV坐标,颜色值等. fixed:低精度浮点值 ...

  2. 详解Java 8中Stream类型的“懒”加载

    在进入正题之前,我们需要先引入Java 8中Stream类型的两个很重要的操作: 中间和终结操作(Intermediate and Terminal Operation) Stream类型有两种类型的 ...

  3. SQL 中不同类型的表连接

    http://www.linuxidc.com/Linux/2012-08/68035.htm 1.简介 在关系型数据库中,join操作是将不同的表中的数据联合在一起时非常通用的一种做法.首先让我们看 ...

  4. Object-C中动态类型对象相关操作汇总

    Object-C(以后简称OC)中有id类型,相对于明确定义类型的静态类型,称为动态类型. 使用动态类型,配合多态(不同类型拥有同名方法),动态绑定(运行时决定实际调用的方法)可以将很多判断延迟到运行 ...

  5. MYSQL中 ENUM 类型

    MYSQL中 ENUM 类型的详细解释 ENUM类型 ENUM 是一个字符串对象,其值通常选自一个允许值列表中,该列表在表创建时的列规格说明中被明确地列举. 在下列某些情况下,值也可以是空串(&quo ...

  6. 第66课 C++中的类型识别

    1. 类型识别 (1)在面向对象中可能出现下面的情况 ①基类指针指向子类对象 ②基类引用成为子类对象的别名 ▲静态类型——变量(对象)自身的类型(定义变量类型时类型或参数类型) ▲动态类型——指针(引 ...

  7. 【翻译自nikic大神】PHP中原生类型的方法

    引言 第一次,翻译别人的文章,用四级英语的水平来翻译~~囧,可能有很多不太恰当的地方,尽管拍砖(有些地方实在想不到恰当的翻译,我同时贴出了原文和自己很low的翻译). 翻译这篇文章用了我3个晚上一个中 ...

  8. SQL批量更新数据库中所有用户数据表中字段类型为tinyint为int

    --SQL批量更新数据库中所有用户数据表中字段类型为tinyint为int --关键说明:--1.从系统表syscolumns中的查询所有xtype='48'的记录得到类型为[tinyint]的字段- ...

  9. NET中的类型和装箱/拆箱原理

    谈到装箱拆箱,DebugLZQ相信给位园子里的博友一定可以娓娓道来,大概的意思就是值类型和引用类型的相互转换呗---值类型到引用类型叫装箱,反之则叫拆箱.这当然没有问题,可是你只知道这么多,那么Deb ...

随机推荐

  1. LeetCode Best Time to Buy and Sell Stock with Transaction Fee

    原题链接在这里:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/descripti ...

  2. VS2013下的64位与32位程序配置

    VS2013下的64位与32位程序配置   在Windows 7 64bit和Visual Studio 2013下生成64位程序. 新建一个Visual Studio Win32 Console项目 ...

  3. 坚持c++,真正掌握c++(4)

    这几天复习了c++primer的第12章类的解说,尽管之前这一章也看了几遍.可是我终究认为书读百遍其义自现,如今我给出一些我学习的心得,欢迎大家一起探讨. 首先,类能够说是c++的灵魂,正由于c++中 ...

  4. Eclipse Failed to load D:\android-sdk-windows\build-tools\27.0.3\lib\dx.jar

    Failed to load D:\android-sdk-windows\build-tools\27.0.3\lib\dx.jar Unknown error: Unable to build: ...

  5. 记录:Web无引用无配置方式动态调用WCF服务

    这几年一直用WebApi较多,最近项目中有个需求比较适合使用WCF,以前也用过JQuery直接调用Wcf的,但是说实话真的忘了… 所以这次解决完还是花几分钟记录一下 WCF服务端:宿主在现有Win服务 ...

  6. composer包php-amqplib

    php-amqplib官方文档 url:http://www.rabbitmq.com/tutorials/tutorial-one-php.html #测试demo: url: http://**. ...

  7. 如何配置Python环境

    (1) 下载:请在Python官网下载页面(https://www.python.org/downloads/)选择合适的版本(建议选择3.5.2版)的链接,在该版本的下载页面选择合适的安装文件:64 ...

  8. date.js

    /** * 此JS文件是格式化JS中日期时间的工具类,其中包含了传入日期对象Date,格式化成想要的格式,<br> * 或者传入字符串格式的时间个,次字符串日期对应的格式可以转换为相应的日 ...

  9. JPype:实现在python中调用JAVA

    一.JPype简述 1.JPype是什么? JPype是一个能够让 python 代码方便地调用 Java 代码的工具,从而克服了 python 在某些领域(如服务器端编程)中的不足. 2.JPype ...

  10. JDBC的复习

    什么是JDBC JDBC(Java DataBase Connectivity)就是Java数据库连接,说白了就是用Java语言来操作数据库.原来我们操作数据库是在控制台使用SQL语句来操作数据库,J ...