Site Administrator
Articles by this Author
Nintendo Wii Console Game
- By Site Administrator
- Published 12/30/2006
- Designing
- Rating: Unrated
| Nintendo Wii Console Game This may perhaps be one of my best tutorials ever. It sure is long though. In less then 45 steps I will teach you how to, not only, make the Wii, but also the Nunchuck and the Wiimote. Never done before. A serious MUST-DO for everyone out there! |
Attachments
Play Action Games - Colection 5
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
Attachments
Play Action Games - Colection 4
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
Attachments
Play Action Games - Colection 3
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
Attachments
Play Action Games - Colection 2
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | Pacific Heroes 2 [download game] Brace yourself for relentless action in WWII’s most important battle! | |
| |
Attachments
Play Action Games - Colection 1
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
Play Action Flash Games Online
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
Attachments
Diesel and Death Game
- By Site Administrator
- Published 10/3/2006
- Flash Action Games
- Rating: Unrated
| Game Information | |
| Author: | Agame.com |
| Description: | Killer motorcycle racing! |
| Instructions: | Right arrow = gas Left arrow = brake Up arrow = jump Down arrow/spacebar = use powerup |
| Size: | 362 KB |
Attachments
Putting the Pieces Together
- By Site Administrator
- Published 10/1/2006
- Macromedia Flash
- Rating: Unrated
Putting the Pieces Together
With all of the classes written, you can now create a FLA that renders a simple 3D scene. In the spirit of my previous automobile examples, I have assembled a set of nodes, lines, and polygons that render the basic shape of a car. Rather than walk you through the code line by line, I have included comments that explain each section:
// import the classes and interfaces for the project
import com.lo9ic.*;
// create the scene movie clip and center it on the stage
var mySceneClip:MovieClip = createEmptyMovieClip("SceneMC", 1);
mySceneClip._x = 275;
mySceneClip._y = 200;
mySceneClip._yscale = mySceneClip._xscale = 250;
// create an instance of the Scene class and set
// the clip and projection factor properties
var myScene:Scene = new Scene();
myScene.clip = mySceneClip;
myScene.f = 200;
// create style objects to be used by lines and polygons
var bodyStyle:Style = new Style();
bodyStyle.fillcolor = "0x660000";
bodyStyle.linecolor = "0x660000";
var grillStyle:Style = new Style();
grillStyle.fillcolor = "0x666666";
grillStyle.linealpha = 0;
var windowStyle:Style = new Style();
windowStyle.fillcolor = "0x000033";
windowStyle.fillalpha = 20;
windowStyle.linecolor = "0x660000";
windowStyle.linealpha = 100;
windowStyle.lineweight = 2;
var antennaStyle:Style = new Style();
var roofStyle:Style = new Style();
var interiorStyle:Style = new Style();
interiorStyle.fillcolor = "0x5F453A";
interiorStyle.linealpha = 0;
var tireStyle:Style = new Style();
tireStyle.fillcolor = "0x333333";
tireStyle.linealpha = 0;
// body panels, grill and trunk nodes
var n0:Node = new Node(-47,20,0);
var n1:Node = new Node(-50,20,15);
var n2:Node = new Node(50,20,15);
var n3:Node = new Node(47,20,0);
var n4:Node = new Node(-47,-20,0);
var n5:Node = new Node(-50,-20,15);
var n6:Node = new Node(50,-20,15);
var n7:Node = new Node(47,-20,0);
// window, hood and trunk lid nodes
var n8:Node = new Node(-22,-20,15);
var n9:Node = new Node(-22,20,15);
var n10:Node = new Node(15,20,15);
var n11:Node = new Node(15,-20,15);
// roof nods
var n12:Node = new Node(14,17,30);
var n13:Node = new Node(-12,17,30);
var n14:Node = new Node(-12,-17,30);
var n15:Node = new Node(14,-17,30);
// the antenna nodes
var n16:Node = new Node(23,20,15);
var n17:Node = new Node(23,20,35);
// the wheel nodes
var n18:Node = new Node(20,20,0);
var n19:Node = new Node(20,20,-10);
var n20:Node = new Node(30,20,-10);
var n21:Node = new Node(40,20,-10);
var n22:Node = new Node(40,20,0);
var n23:Node = new Node(20,-20,0);
var n24:Node = new Node(20,-20,-10);
var n25:Node = new Node(30,-20,-10);
var n26:Node = new Node(40,-20,-10);
var n27:Node = new Node(40,-20,0);
var n28:Node = new Node(-20,20,0);
var n29:Node = new Node(-20,20,-10);
var n30:Node = new Node(-30,20,-10);
var n31:Node = new Node(-40,20,-10);
var n32:Node = new Node(-40,20,0);
var n33:Node = new Node(-20,-20,0);
var n34:Node = new Node(-20,-20,-10);
var n35:Node = new Node(-30,-20,-10);
var n36:Node = new Node(-40,-20,-10);
var n37:Node = new Node(-40,-20,0);
// add the nodes to the scene
for (var i:Number = 0; i<38; i++) {
myScene.addNode(this["n"+i]);
}
// create movie clips for the body panels, windows and antenna
var clip:MovieClip;
for (var i:Number = 0; i<17; i++) {
this["clip"+i] = mySceneClip.createEmptyMovieClip("mc"+i, i+1);
}
// create polygons for the body panels and windows,
// set the clip properties
// and add the polygons to the scene
var poly:Polygon;
for (var i:Number = 0; i<16; i++) {
this["poly"+i] = new Polygon();
this["poly"+i].clip = this["clip"+i];
myScene.addObject(this["poly"+i]);
}
// apply the bodystyle to the body panels
for (var i:Number = 0; i<5; i++) {
this["poly"+i].style = bodyStyle;
}
// apply the grillstyle to the grill
this["poly5"].style = grillStyle;
// apply the roof style to the roof
this["poly6"].style = roofStyle;
// apply the window style to the windows
for (var i:Number = 7; i<11; i++) {
this["poly"+i].style = windowStyle;
}
// apply the interior style to the interior
this["poly11"].style = interiorStyle;
// apply the tire style to the tires
for (var i:Number = 12; i<16; i++) {
this["poly"+i].style = tireStyle;
}
// add the nodes to the polygons
// right body panel
poly0.addNode(n0); poly0.addNode(n1);
poly0.addNode(n2); poly0.addNode(n3);
// left body panel
poly1.addNode(n4); poly1.addNode(n5);
poly1.addNode(n6); poly1.addNode(n7);
// trunk panel
poly2.addNode(n0); poly2.addNode(n1);
poly2.addNode(n5); poly2.addNode(n4);
// trunk
poly3.addNode(n1); poly3.addNode(n4);
poly3.addNode(n8); poly3.addNode(n9);
// hood
poly4.addNode(n11); poly4.addNode(n6);
poly4.addNode(n2); poly4.addNode(n10);
// grill
poly5.addNode(n2); poly5.addNode(n3);
poly5.addNode(n7); poly5.addNode(n6);
// roof
poly6.addNode(n12); poly6.addNode(n13);
poly6.addNode(n14); poly6.addNode(n15);
// windows
poly7.addNode(n9); poly7.addNode(n10);
poly7.addNode(n12); poly7.addNode(n13);
poly8.addNode(n8); poly8.addNode(n11);
poly8.addNode(n15); poly8.addNode(n14);
poly9.addNode(n8); poly9.addNode(n9);
poly9.addNode(n13); poly9.addNode(n14);
poly10.addNode(n11); poly10.addNode(n10);
poly10.addNode(n12); poly10.addNode(n15);
// tires
poly12.addNode(n18); poly12.addNode(n19, true);
poly12.addNode(n20); poly12.addNode(n21, true);
poly12.addNode(n22);
poly13.addNode(n23); poly13.addNode(n24, true);
poly13.addNode(n25); poly13.addNode(n26, true);
poly13.addNode(n27);
poly14.addNode(n28); poly14.addNode(n29, true);
poly14.addNode(n30); poly14.addNode(n31, true);
poly14.addNode(n32);
poly15.addNode(n33); poly15.addNode(n34, true);
poly15.addNode(n35); poly15.addNode(n36, true);
poly15.addNode(n37);
// interior
poly11.addNode(n8); poly11.addNode(n9);
poly11.addNode(n10); poly11.addNode(n11);
// create a line for the antenna
// and add the line to the scene
var antenna = new Line(n16, n17);
antenna.clip = this["clip16"];
antenna.style = antennaStyle;
myScene.addObject(antenna);
// create quaternion for rotating the car into initial position
var myQuat:Quaternion = new Quaternion();
myQuat.fromAxisAngle(1,0,0,-Math.PI/4);
myScene.quaternion.concat(myQuat);
// set the axis and angle of the quaternion, concatenate it with
// the existing quaternion, and draw the scene
function run():Void {
x = Math.sin(getTimer()/5000);
y = Math.cos(getTimer()/5000);
myQuat.fromAxisAngle(0,1,3,.1);
myScene.quaternion.concat(myQuat);
myScene.draw();
}
// set an interval to rotate and draw the scene
var id:Number = setInterval(run, 20);
When you publish the FLA, the resulting movie looks like the one in Figure 1.
Figure 1. A SWF created from 3D classes
I encourage you to download and experiment with this code to create your own 3D scenes or classes. Write a cube or pyramid class that leverages the classes I present here. Hopefully you will find that class-based programming is not only easy to implement but useful in your own projects.
Attachments
Constructing 3D Classes
- By Site Administrator
- Published 10/1/2006
- Macromedia Flash
- Rating: Unrated
Constructing 3D Classes
This section describes how to construct classes that you can use to create 3D objects and environments in Flash. As you examine the code for each class, keep in mind the new features of ActionScript and see how I implement them. You will probably notice a few unfamiliar features of the ActionScript 2.0 syntax; I'll discuss those features along the way.
Drawable
The first piece of code to write is actually an interface, and a very simple one at that. Despite its very short length and simplicity, this interface actually plays an important role later on. The Drawable interface consists of one function declaration:
interface com.lo9ic.Drawable {
function draw():Void;
} All classes that get drawn to the screen implement this interface. Why you do this becomes clear later in the Scene class. Note: The example files are located in the com/lo9ic directory, so the fully qualified includes "com.lo9ic."
Style
The Style class contains styling information for rendering the Drawable classes. This class consists of five private properties, including line weight, line color, line alpha, fill color, and fill alpha; and methods for accessing and setting them:
class com.lo9ic.Style {
private var $linealpha, $lineweight, $fillalpha : Number;
private var $linecolor, $fillcolor : String;
function Style() {
$lineweight = 0;
$linealpha = 100; $fillalpha = 100;
$linecolor = "0x000000"; $fillcolor = "0x000000";
}
public function set linealpha(a:Number):Void {
$linealpha = a;
}
public function set lineweight(a:Number):Void {
$lineweight = a;
}
public function set linecolor(a:String):Void {
$linecolor = a;
}
public function set fillalpha(a:Number):Void {
$fillalpha = a;
}
public function set fillcolor(a:String):Void {
$fillcolor = a;
}
public function get linealpha():Number {
return $linealpha;
}
public function get lineweight():Number {
return $lineweight;
}
public function get linecolor():String {
return $linecolor;
}
public function get fillalpha():Number {
return $fillalpha;
}
public function get fillcolor():String {
return $fillcolor;
}
}
This code implements a new feature of ActionScript 2.0 referred to as an implicit getter/setter function. An example of this function is one of the many functions that contain get or set immediately following the keyword() function. Implicit getter/setter functions allow you to make the properties of an object private and write functions that get and set the value of the properties, following good object-oriented coding practice. The advantage to using implicit getter/setter functions is that you can change the internal representation of a property without breaking other code that relies on the presence of those properties.
Notice that there is an extra function in the class that has exactly the same name as the class itself. This function is referred to as the constructor function. In ActionScript 2.0, constructor functions initialize the value of member properties and are executed whenever a new instance of the class is instantiated.
Node
Nodes are points in 3D space to which the endpoints and control points of lines, curves, and polygons are attached. Rather than belonging exclusively to one 3D object, nodes are often shared to increase the efficiency of a 3D engine. For example, you can define each face of a cube by four points. Because there are six faces in a cube, you need 24 points to define all faces. However, if the faces are allowed to share points, then only eight are required, reducing the number 3D points that the engine has to rotate to one-third the original number.
Before constructing the Node class, let's take note of the properties and methods that it has to implement. First, the Node class contains x, y, and z properties that correspond to the three coordinates of 3D space. Second, each node is rotated using quaternions as I mentioned in the previous section; this means you have to write a Rotate method that takes a quaternion as an argument. Finally, a function that projects a 3D point to a 2D screen using a projection factor completes the class.
Here is the final code for the Node class:
import com.lo9ic.Quaternion;
class com.lo9ic.Node {
private var $x, $y, $z, $xp, $yp, $zp:Number;
private var $q1, $q2, $q3:Quaternion;
function Node(a:Number, b:Number, c:Number) {
$x = a ? a : 0; $xp = $x;
$y = b ? b : 0; $yp = $y;
$z = c ? c : 0; $zp = $z;
}
public function get x():Number {
return $xp;
}
public function get y():Number {
return $yp;
}
public function get z():Number {
return $zp;
}
public function set x(a:Number):Void {
$x = a;
}
public function set y(a:Number) :Void {
$y = a;
}
public function set z(a:Number):Void{
$z = a;
}
public function rotate(q:Quaternion):Void {
$q1 = q.copy();
$q1.invert();
$q2 = new Quaternion();
$q2.fromPoint($x, $y, $z);
$q3 = q.copy();
$q2.concat($q1);
$q3.concat($q2);
$xp = $q3.x;
$yp = $q3.y;
$zp = $q3.z;
}
public function project(a:Number):Void {
$xp = a*$xp/($zp-a);
$yp = a*$yp/($zp-a);
$zp = $zp;
}
}
Quaternion
The Quaternion class creates and stores axis and angle information. It contains properties and getter/setter functions for each of the four coordinates of the quaternion. It also contains methods that set the angle and rotation of the quaternion—one using the three coordinates of a point and one using an axis and an angle. The three additional functions for concatenating, inverting, and copying the quaternion are used for rotation and should look familiar from the rotate() method in the Node class.
Here is the final code for the Quaternion class:
class com.lo9ic.Quaternion {
private var $x, $y, $z, $w:Number;
function Quaternion(a:Number, b:Number, c:Number, d:Number) {
$x = a ? a : 0;
$y = b ? b : 0;
$z = c ? c : 0;
$w = d ? d : 1;
}
public function get x():Number {
return $x;
}
public function get y():Number {
return $y;
}
public function get z():Number {
return $z;
}
public function get w():Number {
return $w;
}
public function fromPoint(a:Number, b:Number, c:Number):Void
{
$x = a;
$y = b;
$z = c;
$w = 0;
}
public function fromAxisAngle(a:Number, b:Number,
c:Number, d:Number):Void
{
var ca = Math.cos(d/2); var sa = Math.sin(d/2);
var m = Math.sqrt(a*a + b*b + c*c);
$x = a/m * sa;
$y = b/m * sa;
$z = c/m * sa;
$w = ca;
}
public function concat(q:Quaternion):Void
{
var w1 = $w; var x1 = $x; var y1 = $y;
var z1 = $z;
var w2 = q.w; var x2 = q.x; var y2 = q.y;
var z2 = q.z;
$w = w1*w2 - x1*x2 - y1*y2 - z1*z2
$x = w1*x2 + x1*w2 + y1*z2 - z1*y2
$y = w1*y2 + y1*w2 + z1*x2 - x1*z2
$z = w1*z2 + z1*w2 + x1*y2 - y1*x2
}
public function invert():Void {
$x = -$x;
$y = -$y;
$z = -$z;
}
public function copy():Quaternion {
return new Quaternion($x, $y, $z, $w);
}
} Line
The first class that uses the Drawable interface is the Line class. Instances of Line define a line in 3D space using two nodes as endpoints. The class also contains style and clip properties for the visual display. Just as you have done before, you have to create getter/setter functions for each property to access the private variables:
import com.lo9ic.Node;
import com.lo9ic.Style;
import com.lo9ic.Drawable;
class com.lo9ic.Line implements Drawable {
private var $startnode, $endnode:Node;
private var $style:Style;
private var $clip:MovieClip;
function Line(a:Node, b:Node) {
$startnode = a ? a : new Node();
$endnode = b ? b : new Node();
$style = new Style();
}
public function set startnode(a:Node):Void {
$startnode = a;
}
public function set endnode(a:Node):Void {
$endnode = a;
}
public function get startnode():Node {
return $startnode;
}
public function get endnode():Node {
return $endnode;
}
public function set style(a:Style):Void {
$style = a ? a:$style;
}
public function get style():Style {
return $style;
}
public function set clip(a:MovieClip):Void {
$clip = a;
}
public function draw():Void {
$clip.clear();
$clip.moveTo($startnode.x, $startnode.y);
$clip.lineStyle($style.lineweight,
$style.linecolor, $style.linealpha);
$clip.lineTo($endnode.x, $endnode.y);
$clip.swapDepths(10000+($endnode.z+$startnode.z)/2);
}
}
The draw() method of the Line class uses the drawing API to draw a line with the attributes specified in the Style property inside the movie clip referenced by the Clip property. The last line of code modifies the depth of the target clip so that it appears to be in front of other objects with lower average z values. This stacks objects that are closer to the viewer in a 3D environment on higher layers, which makes the scene more realistic.
Curve
Extend the Line class to create the Curve class because it shares so many of the same methods and properties. Like the Line class, the Curve class has a Drawable object, so implement the Drawable interface as well. Adding a property and getter/setter methods for the control point completes the new methods and properties for the class. As you did with Line, define a draw() method to complete the Drawable interface:
import com.lo9ic.Node;
import com.lo9ic.Style;
import com.lo9ic.Line;
import com.lo9ic.Drawable;
class com.lo9ic.Curve extends Line implements Drawable {
private var $controlnode : Node;
function Curve(a:Node, b:Node, c:Node) {
$startnode = a ? a : new Node();
$endnode = b ? b : new Node();
$controlnode = c ? c : new Node();
}
public function set controlnode(a:Node):Void {
$controlnode = a;
}
public function get controlnode():Node {
return $controlnode;
}
public function draw():Void {
$clip.clear();
$clip.moveTo($startnode.x, $startnode.y);
$clip.lineStyle($style.lineweight,
$style.linecolor, $style.linealpha);
$clip.curveTo($controlnode.x,
$controlnode.y, $endnode.x, $endnode.y);
$clip.swapDepths(10000+($endnode.z+$startnode.z+
$controlnode.z)/3);
}
}
Polygon
A polygon is a flat surface in 3D space that uses nodes for its corners. In 3D environments, polygons are often patched together to create more complex surfaces and solid objects. Like Line and Curve, the Polygon class has a Style and Clip property and getter/setter methods, and implements the Drawable interface:
import com.lo9ic.Drawable;
import com.lo9ic.Node;
import com.lo9ic.Style;
class com.lo9ic.Polygon implements Drawable {
private var $nodes:Array;
private var $style:Style;
private var $clip:MovieClip;
private var $i, $j, $z:Number; function Polygon() {
$nodes = new Array();
$style = new Style();
}
public function addNode(a:Node, b:Boolean) {
$nodes.push({node:a, control:b});
}
public function set style(a:Style):Void {
$style = a ? a:$style;
}
public function get style():Style {
return $style;
}
public function set clip(a:MovieClip):Void {
$clip = a;
}
public function draw():Void {
$i = 1;
$j = 1;
$z = 0;
$clip.clear();
$clip.moveTo($nodes[0].node.x, $nodes[0].node.y);
$clip.lineStyle($style.lineweight,
$style.linecolor, $style.linealpha);
$clip.beginFill($style.fillcolor, $style.fillalpha);
while( $i <= $nodes.length) {
$j = $i%$nodes.length;
if(!$nodes[$j].control && !$nodes[$i-1].control) {
$clip.lineTo($nodes[$j].node.x, $nodes[$j].node.y);
} else if ($nodes[$i-1].control) {
$clip.curveTo($nodes[$i-1].node.x,
$nodes[$i-1].node.y, $nodes[$j].node.x,
$nodes[$j].node.y);
}
$z += $nodes[$j].node.z;
$i++;
}
$clip.endFill();
$clip.swapDepths(10000+$z/$nodes.length);
}
}
Instead of having endpoint or control point properties, the Polygon class uses an array of nodes to define corners. The addNode() method provides a way to add nodes to this array, optionally allowing you to specify whether the node is a control point. The draw() method loops through this array, connecting the nodes and filling the area in between to form a surface with straight and curved boundaries. The implementation of the draw() method for the Polygon class is a little more complex than either Line or Curve because of the varying number of points a polygon can have.
Scene
The Scene class, the final one you need to learn about, manages the rendering and rotation of all objects in a 3D environment. This class contains two arrays for managing nodes and drawable objects, a quaternion for rotation, and the property "f" that is the projection factor I mentioned earlier in the Node class section. The Scene class itself is not rendered, but the objects within it are, so it makes sense to have Scene implement the Drawable interface as well. The addNode() and addObject() methods allow you to add nodes, lines, curves, and polygons to the scene; the draw() method loops through the node and object arrays, calling the Draw method on each node or object in the scene:
import com.lo9ic.Style;
import com.lo9ic.Quaternion;
import com.lo9ic.Node;
import com.lo9ic.Drawable;
class com.lo9ic.Scene implements Drawable {
private var $f:Number;
private var $nodes:Array;
private var $objects:Array;
private var $quaternion:Quaternion;
private var $clip:MovieClip;
private var $i:Number;
function Scene() {
$f = 300;
$nodes = new Array();
$objects = new Array();
$quaternion = new Quaternion();
}
public function get f():Number {
return $f;
}
public function set f(a:Number):Void {
$f = a;
}
public function set quaternion(a:Quaternion):Void {
$quaternion = a;
}
public function get quaternion():Quaternion {
return $quaternion;
}
public function set clip(a:MovieClip):Void {
$clip = a;
}
public function get clip():MovieClip {
return $clip;
}
public function addNode(a:Node):Void {
$nodes.push(a);
}
public function addObject(a:Drawable):Void {
$objects.push(a);
}
public function draw():Void {
$i = 0;
while($i<$nodes.length) {
$nodes[$i].rotate($quaternion);
$nodes[$i].project($f);
$i++;
}
$i = 0;
while($i<$objects.length) {
$objects[$i].draw();
$i++;
}
}
}
By using an interface for the line, curve, and polygon classes, you simplify the process of adding objects to the scene with a single function that takes an object of type Drawable as the argument. The implementation of the interface for these classes also has the effect of reducing the number of loops required in the draw() method.
Attachments
Doing Quaternion Math
- By Site Administrator
- Published 10/1/2006
- Macromedia Flash
- Rating: Unrated
Doing Quaternion Math
If you've spent any time looking for ways to create 3D objects or scenes you've probably encountered quaternions at one point or another. Quaternions are four-dimensional objects that use w, x, y, and z components to describe an axis of rotation and an angle. Quaternions are often used in 3D engines to rotate points in space quickly. Because quaternions contain only four variables, they require less memory and fewer calculations when compared to 3D matrix methods. This makes them ideal for scripting languages like ActionScript.
Without going into the gory details behind the mathematics of quaternions, where they came from, and why they work the way they do, I present a few simple equations that you can use to construct quaternions:
ca = Math.cos(angle/2);
sa = Math.sin(angle/2);
m = Math.sqrt(x*x + y*y + z*z);
Qx = a/m * sa;
Qy = b/m * sa;
Qz = c/m * sa;
Qw = ca;
In the equations above, the variables x, y, and z are the x, y, and z components of the axis of rotation, angle is the angle in radians, and Qx, Qy, Qz, and Qw are the components of the resulting quaternion. As it turns out, these are the exact equations that we will use later in the Quaternion class.
An important feature of quaternions is that you can multiply, or concatenate, them together to create a composite quaternion that is a combination of the two axes and rotations defined by each. Whenever you require multiple rotations, concatenation saves processing time by eliminating the need to rotate each point separately by each quaternion. The equations for concatenating quaternions are also quite simple:
Q2*Q1 = Q1w*Q2w – Q1x*Q2x – Q1y*Q2y – Q1z*Q2z,
Q1w*Q2x + Q1x*Q2w + Q1y*Q2z – Q1z*Q2y,
Q1w*Q2y + Q1y*Q2w + Q1z*Q2x – Q1x*Q2z,
Q1w*Q2z + Q1z*Q2w + Q1x*Q2y – Q1y*Q2x
Another important feature of Quaternions is that you can convert 3D points into quaternion notation simply by setting the x, y, and z components of the quaternion to be the x, y, and z components of the point and by setting the w component to zero. After you convert a point you can multiply it by a quaternion to rotate the point in space. When you write the Quaternion and Node classes in the next section, you will see how this is done in code.
Attachments
Blogs by this Author
Adobe celebrates 25th anniversary
- By Site Administrator
- Published 01/26/2008
Engaging mobile experiences
- By Site Administrator
- Published 01/26/2008
Adobe Production Studio To Be Available for Both Mac and Windows
- By Site Administrator
- Published 02/9/2007
Adobe to Release PDF for Industry Standardization
- By Site Administrator
- Published 02/9/2007
Adobe Stock Photos reaches one million royalty-free images
- By Site Administrator
- Published 02/9/2007
Introducing Adobe Photoshop Lightroom
- By Site Administrator
- Published 02/9/2007
Adobe RoboHelp 6 is now shipping
- By Site Administrator
- Published 02/9/2007
Get the Adobe Photoshop CS3 beta
- By Site Administrator
- Published 12/19/2006
Now available: Adobe Reader 8
- By Site Administrator
- Published 12/19/2006
Adobe Acrobat 8 Professional
- By Site Administrator
- Published 10/11/2006
