Chapter 34 Example 4
♥0 |
Line 20 |
Modified 2010-02-09 05:28:06 |
MIT License
archived:2017-03-10 18:16:28
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qSnP
*/
package {
import com.actionscriptbible.Example;
import flash.geom.Vector3D;
public class ch34ex4 extends Example{
public function ch34ex4() {
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
}
}
}