The contact PV3D the engine, but also a semi-3D programming solution, so Mark two articles, to prepare for their own learning PV3D with ..

The initial value of the human matrix with 9 (Matrix), to represent a three-dimensional object rotating position. Its major flaw is the data, and can not be automatically generated between the two over the angle of view.

As the matrix description is too abstract point of view, mankind invented the three priorities of the value of pull angle (Euler). You can pull angle is a very irresponsible man, the number of rotations and rotation in order not do distinction. 3D animator one of the most offensive situations 'universal lock (Gimbal Lock)' is this guy's problem. You pull in different axis angle spinning a few times, there x, y, z 3 axis fully into the situation with, say, pull angle You can easily rotate to the end there can be rotated in one direction only case This is the terror of 'universal lock'.

Later, the clever Irish mathematician invented to study today Quaternion (Quaternion), which is three-dimensional rotation relative to date describe the perfect program.

Quaternion and Matrix, as the exchange rate does not meet the multiplication, that is, A * B is not equal B * A. Quaternion can clearly stating the reason why three-dimensional rotation, because he is actually a 'four-dimensional' algorithms. Here's 'four-dimensional' is the use of mathematics, do not need to imagine what is the four-dimensional world = _ =, just one more axis, only one more parameter.

We introduce the PV3d in Quaternion commonly used several methods and their use will not involve too deep mathematical knowledge, so do not worry. Quaternion class position in the org-papervision-core-math package.

/ / Constructor Quaternion need four values (she is called four yuan Well =_=), x, y, z is a three-dimensional vector, that 'any axis', w is a scalar, that degrees of rotation. This is the angle of rotation is almost perfect.

Quaternion why not 'absolutely perfect', because the transition rate when interpolation is not constant, and difficult to resolve. However, this compared to 'terrorist universal lock' is already a small problem.

public function Quaternion (x: Number = 0, y: Number = 0, z: Number = 0, w: Number = 1)

/ / The following two months are 'preferred translation of the Latin angle quaternion' and 'conversion from a quaternion matrix'. These are two very common methods, as long as the advantages of an object known to pull angle, or matrix, to generate the corresponding quaternion.

Pv3d in any DisplayObject3D of tranform this property is the transformation of his matrix, this matrix can be obtained from the current rotation quaternion. (Institute of Flab we used the camera rotation on these methods)

public static function createFromEuler (ax: Number, ay: Number, az: Number, useDegrees: Boolean = false)

public static function createFromMatrix (matrix: Matrix3D)

/ / And the above is just the reverse, namely, 'get the advantages of known quaternion pull angle' and 'be known quaternion matrix'

public function toEuler ()

public function get matrix ()

/ / Quaternion interpolation is the most important use of, slerp method parameter, qa position for the start of the rotation quaternion, qb position for the end of the rotation quaternion, apha can be viewed as an interpolation of the position ratio between the value at 0-1.

public static function slerp (qa: Quaternion, qb: Quaternion, alpha: Number)

Perfect rotation of thought is this:

We must first know our start position and end position, end position in many cases with a DisplayObject3D virtual, we can use it. Tranform (a matrix of values), transform into a quaternion that two of the quaternion, we only need to increase the alpha value for each Zhen (from 0-1), can be in between these two quaternions into any number of transition frames quaternion.

Chen then each of this quaternion reverse the matrix by matrix multiplication in the current location of objects, each object can be obtained by Chen's new location.

Here are all the basic quaternion operations (generally used do not need to master), Wiktionary can understand the 'quaternion' more professional interpretation.

Wiktionary - Quaternion (will open in new window)

/ / Request model, quaternion to the origin of the distance, simply means that the length of

public function get modulo ()

/ / Common Rail

public static function conjugate (a: Quaternion)

/ / Scalar multiplication

public static function dot (a: Quaternion, b: Quaternion)

/ / Fork that

public static function multiply (a: Quaternion, b: Quaternion)

/ / Bad request

public static function sub (a: Quaternion, b: Quaternion)

/ / Sum

public static function add (a: Quaternion, b: Quaternion)