7. Vector and Matrix
7.1 Vector
float command creates a variable f with the IEEE single precision (32-bit) floating point. The fval is the initial floating point value. In the case of no fval argument f is set to 0.0.
float2 command creates a D3DXVECTOR2 variable f2 with initial value of f2list. The f2list is a list of two elements of 32-bit floating point. For example, it can be represented as {0.1 0.2} or [list 0.1 0.2].
float3 command creates a D3DXVECTOR3 variable f3 with initial value of f3list. The f3list is a list of three elements of 32-bit floating point. For example, it can be represented as {0.1 0.2 0.3} or [list 0.1 0.2 0.3].
float4 command creates a D3DXVECTOR4 variable f4 with initial value of f4list. The f4list is a list of four elements of 32-bit floating point. For example, it can be represented as {0.1 0.2 0.3 0.4} or [list 0.1 0.2 0.3 0.4].
v is the aberration of vector which can be float2, float3, or float4 in below description.
The [x|y|z|w] is a Bacuks Normal representation which means one of x, y, z, or w.
get[x|y|z|w] v
returns the float value of x, y, z, or w component of the vector vec. The v can be the type float2, float3, float4, or quaternion for existing component.
set[x|y|z|w] v val
sets the x, y, z, or w component of a vector v as the float val. The v can be the type float2, float3, float4, or quaternion for existing component.
set[x|y|z|w]+= $v $val
sets the x, y, z, or w component of vector v as the addition of the corresponding component and the float val. The v can be the type float2, float3, float4, or quaternion for existing component.
set[x|y|z|w]-= $v val
sets the x, y, z, or w component of vector v as the substraction of the corresponding component and the float val. The v can be the type float2, float3, float4, or quaternion for existing component.
set[x|y|z|w]*= $v val
sets the x, y, z, or w component of vector v as the multiplication of the corresponding component and the float val. The v can be the type float2, float3, float4, or quaternion for existing component.
set[x|y|z|w]/= $v val
sets the x, y, z, or w component of vector v as the division of the corresponding component and the float val. The v can be the type float2, float3, float4, or quaternion for existing component.
vLength v
returns the float length of a vector v.
vLengthSq v
returns the square of the float length of a vector v.
vNormalize vout v
gets the normalized vector vout of a vector v.
vHermite vout v1 t1 v2 t2 s
computes the Hermite interpolation between (v1, t1) and (v2, t2) where v is the position and t is the tangent.
Q(s) = (2*v1 2*v2 + t2 + t1)*s3 + (3*v2 3*v1 2*t1 - t2)*s2 + t1*s + v1.
vScale vout v f
computes the scale of vecotr v with float value f
vAdd vout v1 v2
adds two vector v1 and v2
vSubtract vout v1 v2
substracts vector v1 by v2
vDot v1 v2
returns the float dot product of vector v1 and v2
vMaximize vout v1 v2
returns a vector vout that is made up of the largest components of vector v1 and v2
vMinimize vout v1 v2
returns a vector vout that is made up of the largest components of vector v1 and v2
vLerp vout v1 v2 s
performs a linear interpolation between vectors v1 and v2 with factor value s. The linear interpolation formula is (1-s)*v1 + s*v2
vTransform vout v m
transforms vector in v which can be a type of float2, float3, float4 by a given matrix m and return a float4 vector vout.
vBaryCentric vout v1 v2 v3 f g
gets a point in Barycentric coordinates with equation v1 + f*(v2-v1) + g*(v3-v1), using the specified vectors v1, v2, v3 and float parameters f and g.
vCatmullRom vout v1 v2 v3 v4 s
performs a Catmull-Rom interpolation with four vectors and a weighting factor s from 0.0 to 1.0.
vCCW v1 v2
returns the float value by taking the cross product of two 2-D vectors v1 and v2
vCross vout v1 v2
gets the cross product of vector v1 and v2. The vectors must be the type of float3 or float4.
vProject vout v viewPort mProj mView mWorld
projects a 3-D vector from object space into screen space by viewPort and matrix mProj, mView, mWorld. This function only applies for a float3 vector.
vUnProject vout v viewPort mProj mView mWorld
projects a 3-D vector from screen space into object space by viewPort and matrix mProj, mView, mWorld. This function only applies for a float3 vector.
vTransformCoord vout v m
transforms a 2-D or a 3-D vector by matrix m and projects the result back into w = 1.
vTransformNormal vout v m
transforms a 2-D or a 3-D vector normal by matrix m.
7.2 Matrix
matrix command creates a D3DXMATRIX variable m with initial value of mlist. The mlist is a 4x4 list group of 32-bit floating point. For example, it can be represented as {{0.1 0.2 0.3 0.4} {0.1 0.2 0.3 0.4} {0.1 0.2 0.3 0.4} {0.1 0.2 0.3 0.4}} or use list command. The default m is zero valued matrix.
returns the float value of element e in matrix m. e is an integer in the set {11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42 ,43, 44}.
setm m e fval
sets the float point fval to the e element in the matrix m. e is an integer in the set {11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42 ,43, 44}.
mAffineTransform mout fScaling v3RotationCenter qRotation v3Translation
constructs affine transform matrix mout from float fScaling, float3 vector v3RotationCenter, quaternion qRotation, and float3 vector v3Translation.
mDeterminant m
returns the float determinant of the matrix m
mIdentity mout
sets mout as an identity matrix
mInverse mout det m
sets mout as the inverse of the matrix m. det is a float determinant. When det is set to 0 no determinant is returned.
mIsIdentity m
returns boolean 1 if matrix m is an identity matrix.
mLookAtRH mout vEye vAt vUp
constructs a right-hand, look at matrix mout from float3 vEye, vAt, and vUp.
mLookAtLH mout vEye vAt vUp
constructs a left-hand, look at matrix mout from float3 vEye, vAt, and vUp.
mMultiply mout m1 m2
sets mout as the product of m1 and m2, that is m1*m2
mMultiplyTranspose mout m1 m2
sets mout to be the transposed product of m1 and m2, that is (m1*m2)T
mOrthoRH mout w h zn zf
builds a right-handed orthogonal projection matrix mout where w and h are the width and height of the view volume. Zn and zf are z-near and z-far value of the view volume.
2/w 0 0 0
0 2/h 0 0
0 0 1/(zf-zn) 0
0 0 zn/(zn-zf) 1
mOrthoLH mout w h zn zf
builds a left-handed orthogonal projection matrix mout where w and h are the width and height of the view volume. Zn and zf are z-near and z-far value of the view volume. Mout is calcuated as
2/w 0 0 0
0 2/h 0 0
0 0 1/(zf-zn) 0
0 0 zn/(zn-zf) 1
mOrthoOffCenterRH mout l r b c zn zf
builds a customized, right-handed orthogonal projection matrix mout which is calculated from below formula
2/(r-l) 0 0 0
0 2/(t-b) 0 0
0 0 1/(zf-zn) 0
(l+r)/(l-r) (t+b)/(b-t) zn/(zn-zf) 1
mOrthoOffCenterLH mout l r b c zn zf
builds a customized, left-handed orthogonal projection matrix mout which is calculated from below formula
2/(r-l) 0 0 0
0 2/(t-b) 0 0
0 0 1/(zf-zn) 0
(l+r)/(l-r) (t+b)/(b-t) zn/(zn-zf) 1
mPerspectiveRH mout w h zn zf
createss a right-handed perspective projection matrix mout where w and h are width and height of the view volume. Zn and zf are z-near and z-far value of the view volume.
mPerspectiveLH mout w h zn zf
creates a left-handed perspective projection matrix mout where w and h are width and height of the view volume. Zn and zf are z-near and z-far value of the view volume.
mPerspectiveFovRH mout fFovY fAspect zn zf
builds a right-handed perspective projection matrix mout based on a float fFovY, fAspect and z-near/z-far values..
mPerspectiveFovLH mout fFovY fAspect zn zf
builds a left-handed perspective projection matrix based on a field of view float fFovY, fAspect and z-near/z-far values.
mPerspectiveOffCenterRH mout xmin xmax ymin ymax zmin zmax
builds a right-handed perspective projection matrix mout from a volume parameters.
mPerspectiveOffCenterLH mout xmin xmax ymin ymax zmin zmax
builds a left-handed perspective projection matrix mout from a volume parameters.
mReflect mout plane
constructs a matrix mout that reflects the coordinate system about a plane.
mRotationAxis mout v3 fAngle
constructs matrix mout that rotates around the axis specified by float3 vector v3 with angle fAngle.
mRotationQuaternion mout q
constructs a rotation matrix mout from quaternion q.
mRotationX mout fAngle
constructs matrix mout that rotates around the x-axis with angle fAngle.
mRotationY mout fAngle
constructs matrix mout that rotates around the y-axis with angle fAngle.
mRotationYawPitchRoll mout yaw pitch roll
constructs a matrix mout with a specified float yaw, pitch, and roll. It is equvalient to that rotates around z-axis with roll, then around x-axis with pitch, and around y-axis around yaw.
mRotationZ mout fAngle
constructs matrix mout that rotates around the z-axis with angle fAngle.
mScaling mout sx sy sz
constructs a matrix mout that scales along the x-axis with sx, the y-axis with sy, and the z-axis with sz.
mShadow mout v4Light plane
constructs matrix mout that casts a shadow from a light v4Light over the plane.
mTransformation mout v3ScalingCenter v3ScalingRotation v3Scaling
V3RotationCenter v3Rotation v3Translation
constructs a transform matrix mout.
mTranslation mout x y z
constructs matrix mout uses offset x, y, z.
mTranspose mout m
constructs matrix mout of a transpose matrix m.
7.3 Color
color command creates a D3DXCOLOR variable c with initial value of colorlist. The colorlist is a list of four elements of 32-bit floating point. For example, it can be represented as {0.1 0.2 0.3 0.4} or [list 0.1 0.2 0.3 0.4]. The default c value is {0.0 0.0 0.0 0.0}.
- Operations
get[r|g|b|a] c
returns the float value of r, g, b, a of the color c.
set [r|g|b|a] c cval
sets the r, g, b, a of color c as the float cval.
cAdd c c1 c2
adds two color c1 and c2 to create a new color c.
cSubtract c c1 c2
subtracts color c1 by c2 and creates a new color c.
cAdjustContrast c c1 f
adjusts contrast value of color c with float value f and saves to c. If f is zero, then mout is 50 percent gray. If f is 1, then mout is the original color.
CAdjustSaturation c c1 f
adjusts saturation value of color c1 with float value f and saves to c. If f is zero, then mout is 50 percent gray. If f is 1, then mout is the original color
cLerp c c1 c2 s
constructs color c with linear interpolation of two colors c1, c2, and float value s.
CModulate c c1 c2
generates color c by multiplication of two color c1 and c2.
cNegative c c1
generates negative color c of c1.
cScale c c1 s
generates color c by scaling cor c1 with float value s.
7.4 Quaternation
quaternation q [qlist]
quaternation command creates a D3DXQUATERNATION variable q with initial value of qlist. The qlist is a list of four elements of 32-bit floating point. For example, it can be represented as {0.1 0.2 0.3 0.4} or [list 0.1 0.2 0.3 0.4]. The default q value is {0.0 0.0 0.0 0.0}.
- Operations
get[x|y|z|w] q
returns the float value of x, y, z, w of the quaternation q.
set [x|y|z|w] q qval
sets the x, y, z, w of the quaternation q as the float qval.
qBaryCentric q q1 q2 q3 f g
Sets quaternion q in Barycentric coordinates with quaternion parameters q1, q2, q3 and float parameters f and g.
qConjugate q q1
supposes quaternion q1 is (x, y, z, w), the function will set the quaternion q to (-x, -y, -z, w).
qDot q1 q2
returns the dot product of quaternion q1 and q2.
qExp q q1
generates a pure quaternion q1 to a unit quaternion q.
qIdentity q
constructs identity quaternion q.
qInverse q q1
conjugates and renormalizes a quaternion q1 to generate quaternion q.
qIsIdentity q
returns true if q is a identity quaternion.
qLength q
returns the length of quaternion q.
qLengthSq q
returns the square of length of quaternion q.
qLn q q1
generates the natural logarithm of quaternion q1 and stores in q.
qMultiply q q1 q2
multiples two quaternion q1 and q2 then sets the product to q.
qNormalize q q1
sets quaternion q as the unit length of quaternion q1.
qRotationAxis q v3 fAngle
rotates about axis v3 with angle fAngle.
qRotationMatrix q m
creates quaternion q from rotation matrix m.
qRotationYawPitchRoll q yaw pitch roll
generates quaternion q from yaw, pitch, and roll.
qSlerp q q1 q2 s
uses spherical linear interpolation of q1, q2, and s to generate linear interpolates q.
qSquad q q1 qa qb qc
uses spherical quadrangle interpolation to generate interpolates q.
qToAxisAngle qin v3Axis fAngle
computes quaternion qin’s axis and angle of rotation.
7.5 Plane
plane p [plist]
plane command creates a D3DXPLANE variable p with initial value of plist. The plist is a list of four elements of 32-bit floating point. For example, it can be represented as {0.1 0.2 0.3 0.4} or [list 0.1 0.2 0.3 0.4]. The default p value is {0.0 0.0 0.0 0.0}.
getp [a|b|c|d] $p
returns the float value of a, b, c, d of the plane p.
setp [a|b|c|d] $p $pval
sets the a, b, c, d of the plane p as the float pval.
pDot p
returns the product of plane p.
pDotCoord p v3
returns the dot product of plane p and a 3-D vector v3. The w value is supposed to be 1.0.
pDotNormal p v
returns the dot product of plane p and a 3-D vector v. The w value is supposed to be 0.0.
pIntersectLine v p v1 v2
finds the intersection point float3 v between a plane p and a line starting from float3 v1 and ending to float3 v2.
pFromPointNormal p vPoint vNormal
constructs a plane p from a float3 vPoint and float3 vNormal.
pNormalize p p1
constructs plane p with unit length from plane p1.
pFromPoints p v1 v2 v3
constructs plane p with three float3 vectors v1, v2, and v3.
pTransform p p1 m
transforms plane p1 by matrix m and sets result to plane p. The input matrix must be the inverse transpose of the actual transformation.
7.6 Viewport9
Viewport9 is defined as an object of D3DVIEWPORT9.
set vp9 [$app viewport9 {X Y Width Height MinZ MaxZ}]
creates an viewport9 object where the type of X, Y, Width, and Height is dword and the type of MinZ and MaxZ is float. (X, Y) is the coordinate of the upper-left corner of render target surface. (Width, Height) is the width and height of the render target surface. (MinZ, MaxZ) is the minimum and maximum values of the clip volume.
|