snippets
Points along a displacement vector – Part 2
While the last example was supposed to be simple to read and understand, this shows how to do the same thing with much less code by using the built-in vector methods:
Number3D.add(vectorA, vectorB); //adds two vectors //which is much faster than writing vector = vectorA.x + vectorB.x; vector = vectorA.y + vectorB.y; vector = vectorA.z + vectorB.z; Number3D.sub(vectorA, vectorB); //subtracts two vectors vector.multiplyEq(number); //multiplies the x, y, and z by the given number
Look at the following code and compare it to the first example to try and match up what’s happening.
private const NUM_POINTS:int = 150; public function PointsAlongAVector() { var pointA:Number3D = new Number3D(-1000, -800, 500); var pointB:Number3D = new Number3D(12000, 8000, 20000); var vector:Number3D = Number3D.sub(pointB, pointA); var vectorCopy:Number3D = new Number3D(); for(var i:int = 0; i < NUM_POINTS; i++) { vectorCopy.copyFrom(vector); var pointAlongVector:DisplayObject3D = new Plane(null, 10, 10); vectorCopy.multiplyEq(i/NUM_POINTS); pointAlongVector.position = Number3D.add(pointA, vectorCopy); scene.addChild(pointAlongVector); } singleRender(); }
*note – you will need the latest version of Papervision3D to be able to use the “position” property of a DisplayObject3D.
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- FDT Super Awesome March Deal
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
- MorphController – Mighty Morphing Papervision3D
Recent Comments
- list of lpn courses on SpringCamera3D and Driving a Car
- rn to bsn in montgomery al on archive
- PowerPoint Recovery on Eclipse Theme Designer Preview
- cheat mw3 on Test if a plane is within the view of the camera (aka testing if culled)
- Goa Hotels on Looking around the inside of a Sphere
- cheat gratuit on Looking around the inside of a Sphere
- Application Development on Robotlegs + Flight + Union Platform
- nexium on Moving Faces
- buy nexium on Holy Sphere
- buy aldara online on Tweening a “moveForward()” behavior
Categories
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160

