forked from: Chapter 33 Example 4
forked from Chapter 34 Example 4 (diff: 1)
ActionScript3 source code
/**
* Copyright hacker_9p8x8mco ( http://wonderfl.net/user/hacker_9p8x8mco )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eOUt
*/
// forked from actionscriptbible's Chapter 33 Example 4
package {
import com.actionscriptbible.Example;
import flash.geom.Vector3D;
public class ch33ex4 extends Example{
public function ch33ex4() {
var v:Vector3D = new Vector3D(8, 4, 1);
trace(v.length); //9
trace(v.lengthSquared); //81
var a:Vector3D, b:Vector3D, c:Vector3D;
a = new Vector3D(12, 47, 209);
trace(a.dotProduct(Vector3D.X_AXIS)); //12
a = new Vector3D(12, 0, 0); //points along +x
b = new Vector3D(0, 12, 0); //points along +y
c = a.crossProduct(b); //should point along +z, perpendicular to both
trace(c); //Vector3D(0, 0, 144)
c.normalize();
trace(c, c.length); //Vector3D(0, 0, 1) 1
}
}
}
