Slerp Explorer
Slerp allows you to find the quickest path from one rotation to another rotation. In Papervision3D, slerp is a static function of the Quaternion class. The following code shows all the pieces you’ll need to use slerp in your projects:
//the values from your start axis and rotation (x,y,z,rotation) startQuaternion = new Quaternion(0, 1, 0, 1); //the values from your end axis and rotation endQuaternion = new Quaternion(0, 1, 0, 1); /* the next section would go in an update event, like Event.ENTER_FRAME or TimerEvent.TIMER */ //if slerp is 0, the rotation will reflect the startQuaternion //if slerp is 1, the rotation will reflect the endQuaternion //any value between 0 and 1 will be a percentage of the rotation //between the start and end. For example, .5 would be halfway between //start and end. slerp = 0; //transition this up to 1, something like slerp += .01; //the main quaternion that you copy the rotation from quaternion = Quaternion.slerp(startQuaternion, endQuaternion, slerp); //Copies the rotation from the main quaternion into the cube's matrix cube.transform.copy3x3(quaternion.matrix);
To use this example:
- Move the axis and rotation sliders then click “set start”.
- Move the axis and rotation sliders and click “set end”
- Click “slerp from start to end” and you’ll see the cube rotate from the start rotation to the end rotation.
Focus on how the cube is rotating and how you could use that in your projects. Don’t get distracted by the reference axis.
-
Michael Iv
-
Michael Iv
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- 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
- End dump
- Test if a plane is within the view of the camera (aka testing if culled)
- Materials Reference
- Perlin Blob
Recent Comments
- BAM5 on haXe Tutorial
- AlexG on Finding 2D Coordinates of a DisplayObject3D
- Josh on ActionScript 3 – Model View Controller (MVC)
- martin everett on requests
- martin everett on requests
- lillacska on Dragging Spheres
- Guy Ritchie on MXML without the Flex framework
- Pedro on ActionScript 3 – Namespaces
- daveevolve on AS3DMod Perlin Noise
- sebomoto on haXe Tutorial
Categories
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


