Fade in along special curve

I use Loader class to load a picture,such as example.jpg,and I know if I want to realize fade in effect,I can use following code in Event.ENTER_FRAME:
sprite.alpha+=0.05
When I run above code,I can get a fade in effect of example.jpg. But the fade in effect is for the whole example.jpg, now I want to fade in the example.jpg with a special curve,such as number 9,the example.jpg fade in along number 9 curve. I guess it shoud have a mathematical model can realize this special fade in effect,anyone could give me the model of fade in along special curve?
Any Idea will be appreciated.
Thanks.

>>what do you mean by fading a bitmap with a special curve?  and what's the number 9 have to do with a curve?
I mean I show the bitmap with fading in effect, the fading in along with a curve,the curve shape like number 9,like follows:
one step
two step:
three step
How to realize above fading in effect? A source code is better.
Thanks in advance

Similar Messages

  • Using Fade effect along with Wipe effect

    Hi,
    I have a requirement where a ViewStack has 4 VBoxes that should appear/disappear with Wipe + fade effect.
    Now I have added standard wipe effect in my mxml and added the same in VBox's show and hide attributes.
    But how do I add fade effect with it?
    Please help.
    Thanks and regards,
    Amey

    Use <parallel around the effects..
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/Parallel.htm l#includeExamplesSummary
    *example at the very bottom of the page.

  • How can I make a fade out effect at the end of the song in garageband for iPad?

    I want to made this effect but honestly I have no idea about what I have to do. u.u Please help.

    ClaudioWalrus wrote:
    How can I make a fade out effect at the end of the song in garageband for iPad?
    GB for iPad doesn't have volume automation, you'd need to import the project into GB on a Mac to create the fade with a volume curve.
    as an alt, finish your song and export the audio file, then import the audio file in an audio editor and create a volume fade with that:
    http://www.bulletsandbones.com/GB/GBFAQ.html#audioeditors
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • Object Path Outline Stroke creates jagged edges for curve

    When I outline a stroke, the nodes created along the curve are not smooth. Have these weird funky loops.
    Here is the images as just a stroke with 40 point weight. The segment showed has 3 anchor points.
    Here is the funky loops that I discussed above.
    Any idea how to smooth out the curves better and avoid this issue? Trying to build a font in Illustrator before I transfer to Fontographer but this is problematic for all my curves.

    Thanks for taking a look guys. I've attached additional screenshots.
    Here are the anchor points. The nodes and handles all snap to a 10pt grid (sorry about the bounding box, but you can still see the anchor handles in there).
    These are my brush definition settings.
    I did create the curves using pen tool, then applied the brush definition to the path.

  • It's time to fix the Curves adjustment layer

    Many Photoshop users consider the Curves panel to be Photoshop's most important feature. For many Curves users, the Layer panel introduced in CS4 does not offer the speed, the instinctive use, nor the superior results of the older Curves Layer panel. The Curves dialog includes all the features that long-time users rely on. Some of these features have not been included in the Adjustment Layer version. They should all be available in the Layers panel, too.

    Adobe has already done a few things to fix the early complaints about the Curves panel. You can assign a keyboard shortcut to the Targeted Adjustment Tool so that you don't have to click the icon with the mouse. In the Keyboard Shortcut editor, choose Tools from the Shortcuts For menu, then scroll down until you find Targeted Adjustment Tool. There is no shortcut right now, because basically all of them are already in use. You get to pick the shortcut to give up in another part of the program. This shortcut can make it faster to add points by clicking the image (for fans of the old Command-click technique).
    Once your points are added, you can still move them with the arrow keys as you always could. Also (a lot of people don't know this), you can select the next/previous points along your curve by pressing the + or - keys. So if you just need to fine-tune each point, when any point is selected just press + or - to step over to the point you want to adjust and then start hitting the arrow keys.
    If you put these techniques together, it comes very close to the old Command-click and arrow-key techniqes in the old Curves dialog. In the Curves panel you can perform the adjustments described below, using the keyboard to both navigate and adjust the curve points while keeping your eye on the Info panel and the curve shape.
    DMarley wrote:
    The alternative approach is to command-click or shift-command-click on the light point, leave the cursor at that location, and then manipulate the curve point (or points) with the arrow keys. This lets you evaluate changes with the Info panel values which are more reliable than the display appearance. After following the same steps for a dark point, flat sections of the curve can repaired by adding additional points and dragging to straighten the curve throughout the range of the important image areas. The focus should be the Info panel numbers and the shape of the curve.
    Now as far as the size of the graph goes...
    Hudechrome wrote:
    So that there is a qualitative change in how they behave isn't a deal breaker for me unless things like resolution (of the curve change not pixels!) suffers, which in turn is connected to how well one can see and manipulate the curve points. That is where the diminished size of the plot comes into play.
    A lot of people have complained about the smaller size of the Curves panel, but it's only a disadvantage if the Curves panel is left at its default size. If you max out the size of the Curves panel, it turns out that the plot areas in the old Curves dialog and the new Curves panel are both 256 x 256px...exactly the same!

  • Creating tangent lines on curve points

    Hi all,
    I am drawing a best-fit curve that passes through a number of points and then try to calculate the first derivate and so obtain the tangent line of any point along the curve.
    There's lots of public domain code that will calculate a Natural Cubic Spline curve given a set of points. However, given any point on the curve i need to be able to calculate the tangent.
    I'm not mathematically inclined and so don't understand the formulas as the heart of the Natural Cubic Spline curve and so could not program in java on my own the code needed to get the derivative of the formula to get the tangent at any point. Is there any public domain code out there that will do this?
    I've found one that will do it, but it comes with the limitation that "x" dimension must always be increasing which means the curve can't curve back onto itself. Limiting what i could do with it:
    http://www.joma.org/mathDL/4/?pa=co...=401&bodyId=378
    Any help or redirection would be appreciated
    k

    For any cubic curve, the goal is to solve
    the constants in the equation:
    f(t) = a * t^3 + b * t^2 + c * t + d
    Once you know these values, you can easily
    calculate the derivative:
    f'(t) = 3*a*t^2 + 2*b*t + c
    So all you need to know are a, b, c.
    In the implementations you have found, there
    should be a 2D array that stores the values
    of a, b, c and d. You just have to find
    that array.
    In the Curve API available at:
    http://sourceforge.net/projects/curves
    there is a NaturalCubicSpline.java. In there,
    the values for a, b, c and d are stored in
    the data[][] array.
    Another option would be to break the curve
    into line segments, and then just use the slope
    of the line segment.

  • Points inside curved shape

    Hi all,
    I need to extract points(pixels) that lie within a curved shape. The curved shape is formed with four bezier curves.
    I think I could use Shape, contains(), and PathIterator().
    Can anybody direct to a link with some code to try or share some snippets to test?
    Thanks!

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class ContainsTest extends JPanel {
        CubicCurve2D.Double[] curves;
        Path2D.Double curvePath;
        Path2D.Double intxnPath;
        Point2D.Double[] intxns;
        boolean showCurves = true;
        boolean showCurvePath = false;
        boolean showIntxnPath = false;
        JCheckBox[] checkBoxes;
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(curves == null) {
                initialize();
            if(showCurves) {
                g2.setPaint(Color.green.darker());
                for(int j = 0; j < curves.length; j++) {
                    g2.draw(curves[j]);
            if(showCurvePath) {
                g2.setPaint(new Color(220,200,230,125));
                g2.fill(curvePath);
            if(showIntxnPath) {
                g2.setPaint(Color.blue);
                g2.draw(intxnPath);
            // Mark intxns in sequence (clockwise).
            Color[] colors = {
                Color.red, Color.green.darker(), Color.blue, Color.orange
            for(int j = 0; j < intxns.length; j++) {
                g2.setColor(colors[j]);
                g2.fill(new Ellipse2D.Double(intxns[j].x-1.5,
                                             intxns[j].y-1.5, 4, 4));
         * Make up some Bezier (CubicCurve2D) curves and Path2Ds to work with.
        private void initialize() {
            double[] coords = {
                0, 100, 140, 160, 250, 300, 375, 290
            CubicCurve2D.Double curve = new CubicCurve2D.Double();
            curve.setCurve(coords, 0);
            Rectangle r = curve.getBounds();
            double[] destCoords = new double[coords.length];
            curves = new CubicCurve2D.Double[4];
            curvePath = new Path2D.Double();
            for(int j = 0; j < curves.length; j++) {
                curves[j] = new CubicCurve2D.Double();
                // Rotate 90 degrees.
                double phi = Math.toRadians(j*90);
                // Move (50) away from the center.
                double x = -50*Math.cos(phi);
                double y = -50*Math.sin(phi);
                AffineTransform at = AffineTransform.getTranslateInstance(x, y);
                at.rotate(phi, r.getCenterX(), r.getCenterY());
                // Transform coords for setting this next curve.
                at.transform(coords, 0, destCoords, 0, coords.length/2);
                curves[j].setCurve(destCoords, 0);
                curvePath.append(curves[j], false);
            createIntxnPath();
         * Create a Path2D of the curve segments that lie between the
         * points of intersection along each curve.
        private void createIntxnPath() {
            // Collect curve intersection points, moving clockwise.
            intxns = new Point2D.Double[curves.length];
            for(int j = 0; j < curves.length; j++) {
                intxns[j] = getIntersection(j, (j+1)%curves.length);
            // Get path segments of each curve that lies between
            // the points of intersection. Move in reverse order
            // of points, viz, anti-clockwise, for congruency of
            // path segments.
            intxnPath = new Path2D.Double();
            for(int j = curves.length-1; j >= 0; j--) {
                int k = (j-1 >= 0) ? j-1 : curves.length-1;
                Path2D.Double subPath = getSubPath(j, intxns[j], intxns[k]);
                intxnPath.append(subPath, true);
         * Find intersection of two curves.
        private Point2D.Double getIntersection(int index, int index2) {
            Point2D.Double p = new Point2D.Double();
            double flatness = 0.001;
            PathIterator pit = curves[index].getPathIterator(null, flatness);
            double[] coords = new double[2];
            double minDist = Double.MAX_VALUE;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:  // fall through
                    case PathIterator.SEG_LINETO:
                        Point2D.Double p2 =
                            getClosestPoint(index2, coords[0], coords[1]);
                        double dist = p2.distance(coords[0], coords[1]);
                        if(dist < minDist) {
                            minDist = dist;
                            p.setLocation(coords[0], coords[1]);
                        break;
                    case PathIterator.SEG_CLOSE:
                        break;
                    default:
                        System.out.println("unexpected type: " + type);
                pit.next();
            return p;
        }

  • What's better than Illustrator?

    I've been using Illustrator for many years and several versions.  My usage is nominal and occasional/once a week, and I don't get very sophisticated for my needs, so it has been OK so far. I do not do commercial work but know Ai is the "de-facto std".
    But I read this forum often and see many criticisms of Ai and I do have occasional issues with Illy with tools and UI....just not as easy or robust as it could/should be...cumbersome at times.
    I see JET and others here make great use of Illy but also criticize (justifiably) it for not being as good as other vector tools.
    I know there are competitors, Inkscape is free, others less costly than Illy; and seemingly better/easier/faster to use...at least for some things.
    So my question: What is better than Illustrator (I'm using CS5) and why? What can they do better than Ai?  Is it worth having a second program and learning (tho I suspect the learning curve should be easy as they do similar things but have different GUI).  Or replacing Illy with something?
    Pro's/Con's that would make one make the effort to try/use something else?  I don't even know what out there is better than Illy.  I've searched www and got a few hints but nothing very significant.
    Am I wasting my time looking?
    Your feedback welcomed to help me decide whether to explore/trial other programs.

    I see JET and others here...criticize (justifiably) it for not being as good as other vector tools.
    I can't speak for "and others", but since I'm the only one you mention by name:
    If you've already deemed the criticism justifiable, then you must already know what that criticism says. When I criticize Illustrator, I don't just say "Illustrator is crap" and leave it at that, unsupported. I'm careful to explain myself with facts pertinent to the context of the discussion. I actually own and know how to use the other programs to which I compare. I've often posted lists of comparitive features.
    I've always used my real name here and sign all my posts with my initials. So finding my comments is not difficult.
    I know there are competitors, Inkscape is free, others less costly than Illy; and seemingly better/easier/faster to use...at least for some things. So my question: What is better than Illustrator (I'm using CS5) and why? What can they do better than Ai?
    Didn't you just answer your own question? Other than the broadly general things you just mentioned, what program do you want to compare, and for doing what? Surely you're not asking someone to do an exhaustive feature-by-feature comparison between Illustrator and all similar programs in this one thread?
    All you've said about what you use Illustrator for is that your use is nominal, occasional, unsophisticated, and non-commerical. Mine isn't. Commerical graphics has been my livelihood for over 40 years. Vector-based illustration is both a speciality and a passion.
    I...knowAi is the "de-facto std"
    "Defacto standard" is self-fulfilling. It's effectively equivalent to saying "More people use Illustrator because more people use Illustrator."
    So what? More people ride Vespa scooters than KTM motorcycles. But which one would you call "professional quality"? You can use either one to pick up a gallon of orange juice at the corner store. But if you enter an enduro, the KTM will get the job done with alot less stress.
    The myth is that most software buyers choose the best. That's as naive as the faith that most voters do.
    Illustrator has been slothfully resting on its "defacto standard" haunches since the dark ages (AKA the 80s). "Defacto standard" be hanged.
    I do have occasional issues with Illy with tools and UI....just not as easy or robust as it could/should be...cumbersome at times.
    Okay. What issues? State something specific and users actually familiar with other programs can compare.
    This is the 21st century. There's really little new under the sun here. A 2D drawing program is just an interface pasted on top of mostly the same old geometric functionality. The competitive advantage goes to the offering that best (easy) and most fully (robust) empowers the user. The multiplication of easy and robust yields elegance. That's a term I've never applied to Illustrator. Illustrator is one of the oldest of the bunch, lounging under the sun for so long it's at risk of skin cancer. Yet it still fails to provide basic functionality users of other drawing programs have taken for granted for decades.
    Examples that may be germane to your casual, non-commerical use? Try these things in Illustrator:
    Star Tool: Draw a star. Now change the number of points it has.
    Arc Tool: Draw 36 degrees of a circular arc.
    Label that star with a dimension.
    Distribute a group of different objects along a curve.
    Uniformly space Blend steps along a non-uniform curve.
    Attach a Blend to a closed path and have the first/last instances properly positioned.
    Knife Tool: Cut across an open unfilled path.
    Connect a text label to an object that stays connected when you move it.
    Paste a simple graphic into a text string so that it flows with the text.
    Perform a Find/Replace on carriage returns.
    Round Corners: Apply it to an accute or obtuse angle and have it actually yield the radius you specify.
    Crop a raster image.
    Rotate something. Go back later and find out what its rotation angle is.
    Pathfinders: Use them without wrecking existing fills/strokes.
    I could go on (and have). How long a list do you want? All the features/functions associated with the above basic operations (and many more) are substandard, half-baked, or even non-existent in Illustrator. This is "professional"-grade software? No, it's largely consumerish rubbish sold at exhorbitant prices just because it's the "defacto standard."
    Is it worth having a second program and learning...
    Obviously, it is to me (and a third, and a fourth, and...). As I've said many times in this forum, I don't know how anyone can legitimately claim to compare two programs if they've only got workaday familiarity with one.
    As with any other endeavor, the more drawing programs you're comfortable with, the less arduous it is to pick up another, because you tend to pick up on the underlying principles involved, as opposed to just becomming habituated to a particular program's command locations and procedures by rote.
    But you've been using AI for "many years" and find it to be "OK". So if you're happy with it, use it.
    I have a cheap, consumerish Ryobi table saw and it's "OK." But I didn't pay a professional-grade price for it, either. And I'm sure not going to write glorious reviews on it, call it "professional," and get all fearfully brand-loyal defensive about it if someone dares suggest I might ought to learn to use a different one. My use of it, like yours, is merely occasional. But I also presently need to build a TV cabinet, and I'm dreading it. If I were to open a cabinet shop, I'd be much more discriminating, and would do my own homework to make an informed decision.
    Or replacing Illy with something?
    One doesn't have to "replace." There's nothing any more wrong with using more than one 2D drawing program than there is with using more than one 3D modeling program, or raster imaging program, or page layout program, or word processor, or video edting program, or....
    Pro's/Con's that would make one make the effort to try/use something else?
    That depends on what one is doing with it. Not knowing that, I can again only offer generalities that matter to me: If you've only ever used one program of a particulat kind, you're rather in the dark regarding functionality that you may be missing that may be important to you. (Second-degree ignorance: You don't know what you don't know.) If you're mission-dependent upon that one program, you're also kind of captive to the whims and agenda of its vendor.
    That very well may not matter to you, given your nominal, occasional, unsophisticated, and non-commerical use. And if so, that's fine.
    I don't even know what out there is better than Illy. I've searched www and got a few hints but nothing very significant.
    But you just said you've been reading a bunch of posts here which mention other programs.
    Am I wasting my time looking?
    Only you can answer that about your time. Time is all any of us have.
    Your feedback welcomed to help me decide whether to explore/trial other programs.
    No offense, but frankly it sounds like you're just not motivated enough to do your own homework. If you are  sufficiently motivated, visit the websites of other drawing program vendors. Read the features lists. Dowload the demos, read the documentation, and try them out. Visit the programs' user forums. Or, if it's really not that important to you, don't.
    If you've got questions about specific functionality and/or specific programs, be more specific about what you do (or want to do).
    JET

  • Fyi: SoundStudio 3.5 Released

    (Not affiliated, never used it, etc...)
    Sound Studio 3 is an easy-to-use Mac OS X application for recording and editing audio digitally on your computer. Digitize tapes and vinyl records, record live performances, create your own mixes with crossfades, tweak the levels and EQ, apply digital effects, and save in all major file formats with Sound Studio 3!
    New Version 3.5 - Top 10 Changes!
    - New ID3 tag / iTunes metadata editor.
    - Chapters in AAC (.m4a) and Apple Lossless (also .m4a) formats supported.
    - Apple Lossless (.m4a), ADTS AAC (.aac), NeXT/Sun Audio (.au), and Ogg Vorbis (.ogg) file formats added.
    - MP3 and AAC bit rate support improved.
    - Split By Markers enhanced.
    - Several improvements to filter settings, presets, and preview.
    - Playback scrolling preferences added.
    - Several enhancements in marker display, editing, and saving.
    - Several bug fixes in audio editing, filtering, resampling, playback, and saving.
    - Several improvments in key shortcuts, AppleScript, VoiceOver, and Cowbell support.
    - And more, of course!
    Perfect for Podcasts
    With Sound Studio 3 you can record professional sounding Podcasts and other audio dialog. Check out the article on Suggested Recording Hardware to find out more about how to mic properly and other useful audio information.
    Positioned perfectly between more expensive programs with steep learning curves, and far less robust apps, Sound Studio 3 is for anyone who needs to record or edit audio. Some other possible applications include:
    Lectures
    Voice-notes
    Sermons
    Performances
    and more!
    We at Freeverse have always found Sound Studio to be the perfect app for recording voiceovers, tweaking audio , or creating sound effects (monkey noises included of course). We've used it for years to create all the dialog and sound effects in our games, which is why we're so thrilled to be publishing this amazing new edition.
    Detailed Features
    Recording:
    Multi-track support: layer stereo sounds and save in interleaved format
    Audio Unit plug-in effect support
    Saves in MPEG-4 AAC (advanced audio coding) m4a format
    Saves in MP3 when the LAME framework is installed
    Automator support (launch Automator to see the bundled actions)
    Added "New Mono Document" command for quickly creating a monophonic document
    24-bit / 96 kHz sample quality, in stereo or mono
    Low latency monitoring, using Core Audio
    Automatic recording starting and stopping based on timers or audio levels (a.k.a. VOX)
    Editing:
    Sample-accurate edits
    Markers (a.k.a. Cue Points) with text labels
    Time ruler with units for video and film
    Copy-and-paste editing
    Basic mixing edits
    AppleScript and Automator support
    Effects:
    Supports Audio Units
    Dynamics: Compressor, Expander, and Noise Gate
    Equalization: Graphic EQ, Low Pass Filter, and High Pass Filter
    Delay: Chorus, Flanger, Echo, and Reverb
    Volume: Amplify, Fade In/Out/Special, and Normalize
    Repair: Interpolate, Silence, DC Offset, and Swap Channels
    Repair clicks and pops by interpolating samples or silencing them
    Tone, FM, and noise generators
    Pitch adjustment
    Backwards/Reverse Audio
    File Formats:
    AIFF (.aif) and AIFF-C (.aifc) with compression including IMA 4:1
    AAC and MP3 (importing only).
    Sound Designer II
    Wave (.wav, PCM only)
    Tab-delimited text (export only)
    http://www.freeverse.com/soundstudio/

    jalu wrote:
    Does anybody have an idea when this will land in the repos?
    I know, I know, these things take time. No rush, I'm just curious.
    i dont want to be rude, but these kind of questions dont help anyone and dont get it released any sooner.. in the arch way, flag the package "out of date" (if it was not already done) and wait for it.....
    im just pointing this out because it adds noise to the forums....and they are usually answered like allan did.
    now on topic:
    flash videos work full screen with no frame drops...
    youtube's fullscreen is 4:3 with two black bars filling the screen...and of course, as it was reported in the OP, the html5 demo does not work
    the tracemonkey demo showed a big improvement compared to 3.0, although this could be tailored...

  • Full Quality Output?

    Hi,
    I realize there are numerous differences between iMovie '08 and previous versions. However, I would hope the ability to output a movie at full .dv quality is still possible... although I have been unable to find the option. Am I missing it, or is it missing from iMovie?
    Thanks for any and all help,
    TM

    However, I would hope the ability to output a movie at full .dv quality is still possible... although I have been unable to find the option. Am I missing it, or is it missing from iMovie?
    Probably not in the sense of previous iMovie versions. Previously your clips came in (usually as DV), edits were made that created physical files (fade ins, fade outs, transitions, special effects, title sequences, etc.) which were stored in a reference movie representing the current timeline. At any given time this "timeline" reference movie represented the equivalent of your "full quality" movie. (I.e., the reference movie was essentially a "resource list" of files that when played sequentially was the edited movie.) iMovie '08, however, does not create such physical files during the editing process. Instead, think of iMovie '08 as creating a set of "by reference" instructions which tell how you want the source files to be modified in order to create the final product. No movie is actually created until you "publish" or export one. Thus, in theory, you simply "convert" your source files (in whatever compression format they were imported) to a target compression format for a designated use, complete with all of the "by reference edits" as described in "project" file. Thus, the term "full quality" could describe any compression format that can currently be exported by iMovie '08. It is just too bad that iMovie '08 is not currently capable of exporting directly to an MPEG-2/AIFF compression format which would avoid having to re-compress in iDVD as is currently done with the output of any version of iMovie.
    In addition, the term "full quality" has taken on a new meaning in conjunction with GarageBand. iMovie projects opened in GarageBand and "sent" to iDVD are automatically "full quality" since the video content is passed on to iDVD in the same compression format as it was received by GarageBand. The same is also true if you select the "full quality" export option from GarageBand following the chaptering of an iMovie project. For instance, you can export an iPhone version of your project, open it in GarageBand, chapter it, and then export it as "full quality." In this case, the original M4V video and AAC audio are simply placed in an MOV file container along with the chapter text tract. In fact, if you really want to get fancy, you can now even add an alternate audio channel (haven't checked to see if this can now be done in GarageBand as I normally use QT Pro to set alternate audio channels), and play back the clips with alternate audio selection using the updated iPhone software.

  • Java3D About KBCubicSplineSegment

    Why the constructor of KBCubicSplineSegment is non-public�HI cannot use it in my code. I tried to rewrite the constructor in inherited class but failed.
    The compiler notify me "implicit super constructor KBCubicSplineSegment() is not visible.Must explicitly invoke another constructor"
    Why? How can I use this class? Any particular special structure in this class here?
    Edited by: KelvinZhao on Apr 1, 2008 6:59 PM

    The source code here
    ===================================
    001:        /*
    002:         * $RCSfile: KBCubicSplineSegment.java,v $
    003:         *
    004:         * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
    005:         *
    006:         * Redistribution and use in source and binary forms, with or without
    007:         * modification, are permitted provided that the following conditions
    008:         * are met:
    009:         *
    010:         * - Redistribution of source code must retain the above copyright
    011:         *   notice, this list of conditions and the following disclaimer.
    012:         *
    013:         * - Redistribution in binary form must reproduce the above copyright
    014:         *   notice, this list of conditions and the following disclaimer in
    015:         *   the documentation and/or other materials provided with the
    016:         *   distribution.
    017:         *
    018:         * Neither the name of Sun Microsystems, Inc. or the names of
    019:         * contributors may be used to endorse or promote products derived
    020:         * from this software without specific prior written permission.
    021:         *
    022:         * This software is provided "AS IS," without a warranty of any
    023:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
    024:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
    025:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
    026:         * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
    027:         * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
    028:         * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
    029:         * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
    030:         * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
    031:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
    032:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
    033:         * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
    034:         * POSSIBILITY OF SUCH DAMAGES.
    035:         *
    036:         * You acknowledge that this software is not designed, licensed or
    037:         * intended for use in the design, construction, operation or
    038:         * maintenance of any nuclear facility.
    039:         *
    040:         * $Revision: 1.4 $
    041:         * $Date: 2007/02/09 17:20:11 $
    042:         * $State: Exp $
    043:         */
    044:
    045:        package com.sun.j3d.utils.behaviors.interpolators;
    046:
    047:        import javax.media.j3d.*;
    048:        import java.util.*;
    049:        import javax.vecmath.*;
    050:
    051:        /**
    052:         * The KBCubicSplineSegment class creates the representation of a
    053:         * Kochanek-Bartel's (also known as the TCB or Tension-Continuity-Bias
    054:         * Spline.  This class takes 4 key frames as its input (using KBKeyFrame).
    055:         * If interpolating between the i<sup>th</sup> and (i+1)<sup>th</sup> key
    056:         * frame then the four key frames that need to be specified are the
    057:         * (i-1)<sup>th</sup>, i<sup>th</sup>, (i+1)<sup>th</sup>
    058:         * and (i+2)<sup>th</sup>  keyframes in order. The KBCubicSegmentClass
    059:         * then pre-computes the hermite interpolation basis coefficients if the
    060:         * (i+1)<sup>th</sup> frame has the linear flag set to zero. These are used to
    061:         * calculate the interpolated position, scale and quaternions when they
    062:         * requested by the user using the getInterpolated* methods. If the the
    063:         * (i+1)<sup>th</sup> frame's linear flag is set to 1 then the class uses
    064:         * linear interpolation to calculate the interpolated position, scale, heading
    065:         * pitch and bank it returns through the getInterpolated* methods.
    066:         *
    067:         * @since Java3D 1.2
    068:         */
    069:        public class KBCubicSplineSegment {
    070:
    071:            // Legendre polynomial information for Gaussian quadrature of speed
    072:            // for the domain [0,u], 0 <= u <= 1.
    073:
    074:            // Legendre roots mapped to (root+1)/2
    075:            static final double modRoot[] = { 0.046910077, 0.230765345, 0.5,
    076:                    0.769234655, 0.953089922 };
    077:
    078:            // original coefficients divided by 2
    079:            static final double modCoeff[] = { 0.118463442, 0.239314335,
    080:                    0.284444444, 0.239314335, 0.118463442 };
    081:
    082:            // Key Frames
    083:            KBKeyFrame[] keyFrame = new KBKeyFrame[4];
    084:
    085:            // H.C
    086:            Point3f c0, c1, c2, c3; // coefficients for position
    087:            Point3f e0, e1, e2, e3; // coefficients for scale
    088:            float h0, h1, h2, h3; // coefficients for heading 
    089:            float p0, p1, p2, p3; // coefficients for pitch
    090:            float b0, b1, b2, b3; // coefficients for bank
    091:
    092:            // variables for destination derivative
    093:            float one_minus_t_in;
    094:            float one_minus_c_in;
    095:            float one_minus_b_in;
    096:            float one_plus_c_in;
    097:            float one_plus_b_in;
    098:            float ddb;
    099:            float dda;
    100:
    101:            // variables for source derivative
    102:            float one_minus_t_out;
    103:            float one_minus_c_out;
    104:            float one_minus_b_out;
    105:            float one_plus_c_out;
    106:            float one_plus_b_out;
    107:            float dsb;
    108:            float dsa;
    109:
    110:            // Length of the spline segment
    111:            float length;
    112:
    113:            // interpolation type
    114:            int linear;
    115:
    116:            // Default constructor
    117:            KBCubicSplineSegment() {
    118:
    119:                length = 0;
    120:
    121:            }
    122:
    123:            /**
    124:             * Creates a cubic spline segment between two key frames using the
    125:             * key frames provided. If creating a spline between the ith frame and
    126:             * the (i+1)<sup>th</sup> frame then send down the (i - 1)<sup>th</sup>,
    127:             * i<sup>th</sup> , (i+1)<sup>th</sup> and the (i+2)<sup>th</sup> key
    128:             * frames. 
    129:             *
    130:             * @param kf0 (i - 1)<sup>th</sup> Key Frame
    131:             * @param kf1 i<sup>th</sup> Key Frame
    132:             * @param kf2 (i + 1)<sup>th</sup> Key Frame
    133:             * @param kf3 (i + 2)<sup>th</sup> Key Frame
    134:             */
    135:
    136:            KBCubicSplineSegment(KBKeyFrame kf0, KBKeyFrame kf1,
    137:                    KBKeyFrame kf2, KBKeyFrame kf3) {
    138:
    139:                // Copy KeyFrame information
    140:                keyFrame[0] = new KBKeyFrame(kf0);
    141:                keyFrame[1] = new KBKeyFrame(kf1);
    142:                keyFrame[2] = new KBKeyFrame(kf2);
    143:                keyFrame[3] = new KBKeyFrame(kf3);
    144:
    145:                // if linear interpolation is requested then just set linear flag
    146:                // if spline interpolation is needed then compute spline coefficients
    147:                if (kf2.linear == 1) {
    148:                    this .linear = 1;
    149:                } else {
    150:                    this .linear = 0;
    151:                    computeCommonCoefficients(kf0, kf1, kf2, kf3);
    152:                    computeHermiteCoefficients(kf0, kf1, kf2, kf3);
    153:                }
    154:
    155:                length = computeLength(1.0f);
    156:                // System.out.println ("Segment length = " + length);
    157:
    158:            }
    159:
    160:            // compute the common coefficients
    161:            private void computeCommonCoefficients(KBKeyFrame kf0,
    162:                    KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3) {
    163:
    164:                // variables for destination derivative
    165:                float one_minus_t_in = 1.0f - kf1.tension;
    166:                float one_minus_c_in = 1.0f - kf1.continuity;
    167:                float one_minus_b_in = 1.0f - kf1.bias;
    168:                float one_plus_c_in = 1.0f + kf1.continuity;
    169:                float one_plus_b_in = 1.0f + kf1.bias;
    170:
    171:                // coefficients for the incoming Tangent
    172:                ddb = one_minus_t_in * one_minus_c_in * one_minus_b_in;
    173:                dda = one_minus_t_in * one_plus_c_in * one_plus_b_in;
    174:
    175:                // variables for source derivative
    176:                float one_minus_t_out = 1.0f - kf2.tension;
    177:                float one_minus_c_out = 1.0f - kf2.continuity;
    178:                float one_minus_b_out = 1.0f - kf2.bias;
    179:                float one_plus_c_out = 1.0f + kf2.continuity;
    180:                float one_plus_b_out = 1.0f + kf2.bias;
    181:
    182:                // coefficients for the outgoing Tangent
    183:                dsb = one_minus_t_in * one_plus_c_in * one_minus_b_in;
    184:                dsa = one_minus_t_in * one_minus_c_in * one_plus_b_in;
    185:            }
    186:
    187:            // compute the hermite interpolation basis coefficients
    188:            private void computeHermiteCoefficients(KBKeyFrame kf0,
    189:                    KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3) {
    190:
    191:                Point3f deltaP = new Point3f();
    192:                Point3f deltaS = new Point3f();
    193:                float deltaH;
    194:                float deltaT;
    195:                float deltaB;
    196:
    197:                // Find the difference in position and scale
    198:                deltaP.x = kf2.position.x - kf1.position.x;
    199:                deltaP.y = kf2.position.y - kf1.position.y;
    200:                deltaP.z = kf2.position.z - kf1.position.z;
    201:
    202:                deltaS.x = kf2.scale.x - kf1.scale.x;
    203:                deltaS.y = kf2.scale.y - kf1.scale.y;
    204:                deltaS.z = kf2.scale.z - kf1.scale.z;
    205:
    206:                // Find the difference in heading, pitch, and bank
    207:                deltaH = kf2.heading - kf1.heading;
    208:                deltaT = kf2.pitch - kf1.pitch;
    209:                deltaB = kf2.bank - kf1.bank;
    210:
    211:                // Incoming Tangent
    212:                Point3f dd_pos = new Point3f();
    213:                Point3f dd_scale = new Point3f();
    214:                float dd_heading, dd_pitch, dd_bank;
    215:
    216:                // If this is the first keyframe of the animation
    217:                if (kf0.knot == kf1.knot) {
    218:
    219:                    float ddab = 0.5f * (dda + ddb);
    220:
    221:                    // Position
    222:                    dd_pos.x = ddab * deltaP.x;
    223:                    dd_pos.y = ddab * deltaP.y;
    224:                    dd_pos.z = ddab * deltaP.z;
    225:
    226:                    // Scale
    227:                    dd_scale.x = ddab * deltaS.x;
    228:                    dd_scale.y = ddab * deltaS.y;
    229:                    dd_scale.z = ddab * deltaS.z;
    230:
    231:                    // Heading, Pitch and Bank
    232:                    dd_heading = ddab * deltaH;
    233:                    dd_pitch = ddab * deltaT;
    234:                    dd_bank = ddab * deltaB;
    235:
    236:                } else {
    237:
    238:                    float adj0 = (kf1.knot - kf0.knot) / (kf2.knot - kf0.knot);
    239:
    240:                    // Position
    241:                    dd_pos.x = adj0
    242:                            * ((ddb * deltaP.x) + (dda * (kf1.position.x - kf0.position.x)));
    243:                    dd_pos.y = adj0
    244:                            * ((ddb * deltaP.y) + (dda * (kf1.position.y - kf0.position.y)));
    245:                    dd_pos.z = adj0
    246:                            * ((ddb * deltaP.z) + (dda * (kf1.position.z - kf0.position.z)));
    247:
    248:                    // Scale
    249:                    dd_scale.x = adj0
    250:                            * ((ddb * deltaS.x) + (dda * (kf1.scale.x - kf0.scale.x)));
    251:                    dd_scale.y = adj0
    252:                            * ((ddb * deltaS.y) + (dda * (kf1.scale.y - kf0.scale.y)));
    253:                    dd_scale.z = adj0
    254:                            * ((ddb * deltaS.z) + (dda * (kf1.scale.z - kf0.scale.z)));
    255:
    256:                    // Heading, Pitch and Bank
    257:                    dd_heading = adj0
    258:                            * ((ddb * deltaH) + (dda * (kf1.heading - kf0.heading)));
    259:                    dd_pitch = adj0
    260:                            * ((ddb * deltaT) + (dda * (kf1.pitch - kf0.pitch)));
    261:                    dd_bank = adj0
    262:                            * ((ddb * deltaB) + (dda * (kf1.bank - kf0.bank)));
    263:                }
    264:
    265:                // Outgoing Tangent
    266:                Point3f ds_pos = new Point3f();
    267:                Point3f ds_scale = new Point3f();
    268:                float ds_heading, ds_pitch, ds_bank;
    269:
    270:                // If this is the last keyframe of the animation
    271:                if (kf2.knot == kf3.knot) {
    272:
    273:                    float dsab = 0.5f * (dsa + dsb);
    274:
    275:                    // Position
    276:                    ds_pos.x = dsab * deltaP.x;
    277:                    ds_pos.y = dsab * deltaP.y;
    278:                    ds_pos.z = dsab * deltaP.z;
    279:
    280:                    // Scale
    281:                    ds_scale.x = dsab * deltaS.x;
    282:                    ds_scale.y = dsab * deltaS.y;
    283:                    ds_scale.z = dsab * deltaS.z;
    284:
    285:                    // Heading, Pitch and Bank
    286:                    ds_heading = dsab * deltaH;
    287:                    ds_pitch = dsab * deltaT;
    288:                    ds_bank = dsab * deltaB;
    289:
    290:                } else {
    291:
    292:                    float adj1 = (kf2.knot - kf1.knot) / (kf3.knot - kf1.knot);
    293:
    294:                    // Position
    295:                    ds_pos.x = adj1
    296:                            * ((dsb * (kf3.position.x - kf2.position.x)) + (dsa * deltaP.x));
    297:                    ds_pos.y = adj1
    298:                            * ((dsb * (kf3.position.y - kf2.position.y)) + (dsa * deltaP.y));
    299:                    ds_pos.z = adj1
    300:                            * ((dsb * (kf3.position.z - kf2.position.z)) + (dsa * deltaP.z));
    301:
    302:                    // Scale
    303:                    ds_scale.x = adj1
    304:                            * ((dsb * (kf3.scale.x - kf2.scale.x)) + (dsa * deltaS.x));
    305:                    ds_scale.y = adj1
    306:                            * ((dsb * (kf3.scale.y - kf2.scale.y)) + (dsa * deltaS.y));
    307:                    ds_scale.z = adj1
    308:                            * ((dsb * (kf3.scale.z - kf2.scale.z)) + (dsa * deltaS.z));
    309:
    310:                    // Heading, Pitch and Bank
    311:                    ds_heading = adj1
    312:                            * ((dsb * (kf3.heading - kf2.heading)) + (dsa * deltaH));
    313:                    ds_pitch = adj1
    314:                            * ((dsb * (kf3.pitch - kf2.pitch)) + (dsa * deltaT));
    315:                    ds_bank = adj1
    316:                            * ((dsb * (kf3.bank - kf2.bank)) + (dsa * deltaB));
    317:                }
    318:
    319:                // Calculate the coefficients of the polynomial for position
    320:                c0 = new Point3f();
    321:                c0.x = kf1.position.x;
    322:                c0.y = kf1.position.y;
    323:                c0.z = kf1.position.z;
    324:
    325:                c1 = new Point3f();
    326:                c1.x = dd_pos.x;
    327:                c1.y = dd_pos.y;
    328:                c1.z = dd_pos.z;
    329:
    330:                c2 = new Point3f();
    331:                c2.x = 3 * deltaP.x - 2 * dd_pos.x - ds_pos.x;
    332:                c2.y = 3 * deltaP.y - 2 * dd_pos.y - ds_pos.y;
    333:                c2.z = 3 * deltaP.z - 2 * dd_pos.z - ds_pos.z;
    334:
    335:                c3 = new Point3f();
    336:                c3.x = -2 * deltaP.x + dd_pos.x + ds_pos.x;
    337:                c3.y = -2 * deltaP.y + dd_pos.y + ds_pos.y;
    338:                c3.z = -2 * deltaP.z + dd_pos.z + ds_pos.z;
    339:
    340:                // Calculate the coefficients of the polynomial for scale
    341:                e0 = new Point3f();
    342:                e0.x = kf1.scale.x;
    343:                e0.y = kf1.scale.y;
    344:                e0.z = kf1.scale.z;
    345:
    346:                e1 = new Point3f();
    347:                e1.x = dd_scale.x;
    348:                e1.y = dd_scale.y;
    349:                e1.z = dd_scale.z;
    350:
    351:                e2 = new Point3f();
    352:                e2.x = 3 * deltaS.x - 2 * dd_scale.x - ds_scale.x;
    353:                e2.y = 3 * deltaS.y - 2 * dd_scale.y - ds_scale.y;
    354:                e2.z = 3 * deltaS.z - 2 * dd_scale.z - ds_scale.z;
    355:
    356:                e3 = new Point3f();
    357:                e3.x = -2 * deltaS.x + dd_scale.x + ds_scale.x;
    358:                e3.y = -2 * deltaS.y + dd_scale.y + ds_scale.y;
    359:                e3.z = -2 * deltaS.z + dd_scale.z + ds_scale.z;
    360:
    361:                // Calculate the coefficients of the polynomial for heading, pitch
    362:                // and bank
    363:                h0 = kf1.heading;
    364:                p0 = kf1.pitch;
    365:                b0 = kf1.bank;
    366:
    367:                h1 = dd_heading;
    368:                p1 = dd_pitch;
    369:                b1 = dd_bank;
    370:
    371:                h2 = 3 * deltaH - 2 * dd_heading - ds_heading;
    372:                p2 = 3 * deltaT - 2 * dd_pitch - ds_pitch;
    373:                b2 = 3 * deltaB - 2 * dd_bank - ds_bank;
    374:
    375:                h3 = -2 * deltaH + dd_heading + ds_heading;
    376:                p3 = -2 * deltaT + dd_pitch + ds_pitch;
    377:                b3 = -2 * deltaB + dd_bank + ds_bank;
    378:            }
    379:
    380:            /**
    381:             * Computes the length of the curve at a given point between
    382:             * key frames.
    383:             * @param u specifies the point between keyframes where 0 <= u <= 1.
    384:             */
    385:
    386:            public float computeLength(float u) {
    387:
    388:                float result = 0f;
    389:
    390:                // if linear interpolation
    391:                if (linear == 1) {
    392:                    result = u
    393:                            * keyFrame[2].position
    394:                                    .distance(keyFrame[1].position);
    395:                } else {
    396:                    // Need to transform domain [0,u] to [-1,1].  If 0 <= x <= u
    397:                    // and -1 <= t <= 1, then x = u*(t+1)/2.
    398:                    int degree = 5;
    399:                    for (int i = 0; i < degree; i++)
    400:                        result += (float) modCoeff[i]
    401:                                * computeSpeed(u * (float) modRoot);
    402: result *= u;
    403: }
    404:
    405: return result;
    406: }
    407:
    408: // Velocity along curve
    409: private float computeSpeed(float u) {
    410: Point3f v = new Point3f();
    411:
    412: v.x = c1.x + u * (2 * c2.x + 3 * u * c3.x);
    413: v.y = c1.y + u * (2 * c2.y + 3 * u * c3.y);
    414: v.z = c1.z + u * (2 * c2.z + 3 * u * c3.z);
    415:
    416: return (float) (Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
    417: }
    418:
    419: /**
    420: * Computes the interpolated scale along the curve at a given point
    421: * between key frames and returns a Point3f with the interpolated
    422: * x, y, and z scale components. This routine uses linear
    423: * interpolation if the (i+1)<sup>th</sup> key frame's linear
    424: * value is equal to 1.
    425: *
    426: * @param u specifies the point between keyframes where 0 <= u <= 1.
    427: * @param newScale returns the interpolated x,y,z scale value in a Point3f
    428: */
    429:
    430: public void getInterpolatedScale(float u, Point3f newScale) {
    431:
    432: // if linear interpolation
    433: if (this .linear == 1) {
    434:
    435: newScale.x = keyFrame[1].scale.x
    436: + ((keyFrame[2].scale.x - keyFrame[1].scale.x) * u);
    437: newScale.y = keyFrame[1].scale.y
    438: + ((keyFrame[2].scale.y - keyFrame[1].scale.y) * u);
    439: newScale.z = keyFrame[1].scale.z
    440: + ((keyFrame[2].scale.z - keyFrame[1].scale.z) * u);
    441:
    442: } else {
    443:
    444: newScale.x = e0.x + u * (e1.x + u * (e2.x + u * e3.x));
    445: newScale.y = e0.y + u * (e1.y + u * (e2.y + u * e3.y));
    446: newScale.z = e0.z + u * (e1.z + u * (e2.z + u * e3.z));
    447:
    448: }
    449: }
    450:
    451: /**
    452: * Computes the interpolated position along the curve at a given point
    453: * between key frames and returns a Point3f with the interpolated
    454: * x, y, and z scale components. This routine uses linear
    455: * interpolation if the (i+1)<sup>th</sup> key frame's linear
    456: * value is equal to 1.
    457: *
    458: * @param u specifies the point between keyframes where 0 <= u <= 1.
    459: * @param newPos returns the interpolated x,y,z position in a Point3f
    460: */
    461:
    462: public void getInterpolatedPosition(float u, Point3f newPos) {
    463:
    464: // if linear interpolation
    465: if (this .linear == 1) {
    466: newPos.x = keyFrame[1].position.x
    467: + ((keyFrame[2].position.x - keyFrame[1].position.x) * u);
    468: newPos.y = keyFrame[1].position.y
    469: + ((keyFrame[2].position.y - keyFrame[1].position.y) * u);
    470: newPos.z = keyFrame[1].position.z
    471: + ((keyFrame[2].position.z - keyFrame[1].position.z) * u);
    472: } else {
    473:
    474: newPos.x = c0.x + u * (c1.x + u * (c2.x + u * c3.x));
    475: newPos.y = c0.y + u * (c1.y + u * (c2.y + u * c3.y));
    476: newPos.z = c0.z + u * (c1.z + u * (c2.z + u * c3.z));
    477:
    478: }
    479: }
    480:
    481: /**
    482: * Computes the interpolated position along the curve at a given point
    483: * between key frames and returns a Vector3f with the interpolated
    484: * x, y, and z scale components. This routine uses linear
    485: * interpolation if the (i+1)<sup>th</sup> key frame's linear
    486: * value is equal to 1.
    487: *
    488: * @param u specifies the point between keyframes where 0 <= u <= 1.
    489: * @param newPos returns the interpolated x,y,z position in a Vector3f.
    490: */
    491:
    492: public void getInterpolatedPositionVector(float u, Vector3f newPos) {
    493: // if linear interpolation
    494: if (this .linear == 1) {
    495: newPos.x = keyFrame[1].position.x
    496: + ((keyFrame[2].position.x - keyFrame[1].position.x) * u);
    497: newPos.y = keyFrame[1].position.y
    498: + ((keyFrame[2].position.y - keyFrame[1].position.y) * u);
    499: newPos.z = keyFrame[1].position.z
    500: + ((keyFrame[2].position.z - keyFrame[1].position.z) * u);
    501: } else {
    502:
    503: newPos.x = c0.x + u * (c1.x + u * (c2.x + u * c3.x));
    504: newPos.y = c0.y + u * (c1.y + u * (c2.y + u * c3.y));
    505: newPos.z = c0.z + u * (c1.z + u * (c2.z + u * c3.z));
    506:
    507: }
    508: }
    509:
    510: /**
    511: * Computes the interpolated heading along the curve at a given point
    512: * between key frames and returns the interpolated value as a float
    513: * This routine uses linear interpolation if the (i+1)<sup>th</sup>
    514: * key frame's linear value is equal to 1.
    515: *
    516: * @param u specifies the point between keyframes where 0 <= u <= 1.
    517: * @return returns the interpolated heading value
    518: */
    519:
    520: public float getInterpolatedHeading(float u) {
    521:
    522: float newHeading;
    523:
    524: // if linear interpolation
    525: if (this .linear == 1) {
    526:
    527: newHeading = keyFrame[1].heading
    528: + ((keyFrame[2].heading - keyFrame[1].heading) * u);
    529: } else {
    530:
    531: newHeading = h0 + u * (h1 + u * (h2 + u * h3));
    532:
    533: }
    534:
    535: return newHeading;
    536: }
    537:
    538: /**
    539: * Computes the interpolated pitch along the curve at a given point
    540: * between key frames and returns the interpolated value as a float
    541: * This routine uses linear interpolation if the (i+1)<sup>th</sup>
    542: * key frame's linear value is equal to 1.
    543: *
    544: * @param u specifies the point between keyframes where 0 <= u <= 1.
    545: * @return returns the interpolated pitch value
    546: */
    547:
    548: public float getInterpolatedPitch(float u) {
    549:
    550: float newPitch;
    551:
    552: // if linear interpolation
    553: if (this .linear == 1) {
    554:
    555: newPitch = keyFrame[1].pitch
    556: + ((keyFrame[2].pitch - keyFrame[1].pitch) * u);
    557: } else {
    558:
    559: newPitch = p0 + u * (p1 + u * (p2 + u * p3));
    560:
    561: }
    562:
    563: return newPitch;
    564: }
    565:
    566: /**
    567: * Computes the interpolated bank along the curve at a given point
    568: * between key frames and returns the interpolated value as a float
    569: * This routine uses linear interpolation if the (i+1)<sup>th</sup>
    570: * key frame's linear value is equal to 1.
    571: *
    572: * @param u specifies the point between keyframes where 0 <= u <= 1.
    573: * @return returns the interpolated bank value
    574: */
    575:
    576: public float getInterpolatedBank(float u) {
    577:
    578: float newBank;
    579:
    580: // if linear interpolation
    581: if (this .linear == 1) {
    582:
    583: newBank = keyFrame[1].bank
    584: + ((keyFrame[2].bank - keyFrame[1].bank) * u);
    585: } else {
    586:
    587: newBank = b0 + u * (b1 + u * (b2 + u * b3));
    588:
    589: }
    590:
    591: return newBank;
    592: }
    593:
    594: /**
    595: * Computes the ratio of the length of the spline from the i<sup>th</sup>
    596: * key frame to the position specified by u to the length of the entire
    597: * spline segment from the i<sup>th</sup> key frame to the (i+1)
    598: * <sup>th</sup> key frame. When the (i+1)<sup>th</sup> key frame's linear
    599: * value is equal to 1, this is meaninful otherwise it should return u.
    600: *
    601: * @param u specifies the point between keyframes where 0 <= u <= 1.
    602: * @return the interpolated ratio
    603: */
    604:
    605: public float getInterpolatedValue(float u) {
    606: return (computeLength(u) / this.length);
    607: }
    608: }Edited by: KelvinZhao on Apr 1, 2008 7:10 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Warped Text in PS CS6

    I need help in typing text along a curved path in PS CS6.   I have watched and read several on-line tutorials and they all seem to say about the same thing and seem pretty simple.   I create a path using the pen tool.  Next I select the Type tool.  I position the cursor over the path where I want to start typing.   The cursor changes to show the little curved line.   I left click once.    A bar perpendicular to the path appears.    I start typing and nothing appears.   I think I have the font size & color properly selected, because I have no difficulty in typing text in an ordinary text box.   Any idea as to what I am doing wrong?

    Type something and OK it.  Then either double click the type layer, or use Free Transform on the type layer.  Either will highlight the text showing its size etc.
    DougStocks1 wrote:
    but do not see a "menu" button;
    The drop down in top right corner of panel
    DougStocks1 wrote:
    however all the parameters appear to me to be acceptable.   
    And yet you have not text, could it possibly be that you are wrong?

  • Creation of multiple geometric template

    i have various templates and want to create a multiple geometric template file
    i am unable to do it.
    i have uploaded the templates
    please help me with it
    -$hiv@
    Solved!
    Go to Solution.
    Attachments:
    five(OK).png ‏342 KB
    five3(OK).png ‏269 KB
    five4(OK).png ‏1694 KB

    Both geometric matching techniques rely on curves extracted from image to perform the matching. The two geometric matching techniques differ in how the curve information is used to perform the matching. The edge-based geometric matching method computes the gradient value of the edge at each point along the curves found in the image and uses the gradient value and the position of the point from the center of the template to perform the matching. The feature-based geometric matching method extracts geometric features from the curves and uses these geometric features to perform the matching.
    You can find more detailed information in the NI Vision Concepts Manual here:
    http://zone.ni.com/reference/en-XX/help/372916L-01/nivisionconcepts/geometric_matching_technique/
    The article also explain when it is better to use one versus the other.
    I couldn't test the templates yesterday, because you did not attach a match image.
    I might be wrong, but another thing I noticed is that it looks like you thresholded the images prior to extracting the templates. In general, algorithms that need to extract edges from images, such as geometric matching, will work better when you provide them with the grayscale image, as opposed with a thresholded image. The contour extraction will be more accurate. Also, the algorithm does not only use contour information, but also grayscale information of the image. By thresholding the image, one removes a lot of information that the algorithm can use.
    On a last note, combining templates into one is only going to help with speed. If speed is not an issue in your application, you can still learn with Edge Based matching and match all template. If there is a match, the character/number you looked for is the right one.
    Another solution might be to use a reverse technique, still using Edge Based matching that seems to work better in your case. We sometimes use it to solve classification applications similar to what you are trying to do:
    Instead of learning multiple templates and trying to locate them in your image, take the opposite approach: create a synthetic image that contain your templates (all rotated 1s on one line... all rotated 5s on another line etc). Then if you can locate and extract the number (using blob analysis) on the original image, you can extract that region, learn it as a template, and look for it in the synthetic image. The line you find it indicates which digit it is.
    Again, this technique might work if you can extract the digit you're trying to identify from the original image. Performance wise, it is only interesting if learning the extracted digit on the fly is faster than trying to match all the separate templates (learning takes more time than matching).
    It looks like you're trying to perform OCR on the image. Again, if the text is always located at the same place and you can draw a region of interest around it, you can try the OCR algorithm and define different classes that have the same label for the different rotated digits.
    I tried to give you different possible approaches. Hope that was not too confusing.
    Best regards,
    -Christophe

  • Finding the length of a path

    hey,
    i'm using cs3 and i have a few simple paths (curves) and i'd like to know the length of these curves but i can't seem to find an option, or whatever, for that.
    thanks

    You mean the length as you travel along the curves?
    Can't be done I'm afraid, at least not very accurately.
    If it's really important you could try arranging a whole lot of little squares along the path so that they touch each other and then counting them. But the result won't be accurate unless the squares are very small.
    However, if you know how the curves are constructed geometrically you can sometimes calculate their lengths.
    For example if the curve is an arc of a circle and you know the angle it subtends as a proportion of 360 degrees then it's fairly easy to use pi to find the length of it.
    Circumference of a circle = pi x diameter.
    "As every skoolboy kno" (nigel molesworth)
    Ellipses are more of a bother and I don't know the formulas for sinus curves, parabolas and that sort of thing.

  • Line chart in javafx

    I have to animate line chart in javafx?
    Can anybody help?????????

    a_b_g wrote:
    If you are trying to create a moving chart, your trace is a series of lines with their values in a sequence. To make the chart move, delete the last value in the sequence then insert to new current value at the beginning of the sequence. This has the effect of moving the whole sequence up 1 position
    alexpackage areachart1;
    import javafx.animation.Timeline;
    import javafx.animation.Interpolator;
    import javafx.scene.Scene;
    import javafx.scene.chart.LineChart;
    import javafx.scene.chart.part.NumberAxis;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    *@author Administrator*
    var x : Number = 0;
    var y : Number = 0;
    Timeline {
    repeatCount: 1
    keyFrames: [
    at (1s) {x => 0.0; y => 0.0;}
    at (2s) {x => 1.0; y => 1.0;}
    at (3s) {x => 2.0; y => 2.0;}
    at (4s) {x => 3.0; y => 1.0;}
    at (5s) {x => 4.0; y => 0.0;}
    }.play();
    Stage {
    title: "Application title"
    scene: Scene {
    width: 600
    height: 600
    content: [
    VBox {
    content: [
    LineChart {
    title: "Clarification Dynamics"
    dataEffect: null
    xAxis: NumberAxis {
    lowerBound: 0
    upperBound: 10
    label: "Suspended solids conc. (kg/m2)"
    yAxis: NumberAxis {
    lowerBound: 0
    upperBound: 10
    label: "Solid Flux"
    tickMarkVisible: false
    data: [
    LineChart.Series {
    data: [
    LineChart.Data {xValue:  bind x yValue: bind y }
    LineChart.Data {xValue: bind x+1 yValue: bind y+1 }
    *{color:#800080}*
    this is the code that i had written
    but in this a line is created and it moves along a curved path as specified...
    but i have to show a graph being plotted from origin to some x,y coordinates...
    *can anybody help...{color}*
    Edited by: sshruti_remo on Jun 1, 2010 2:43 AM

Maybe you are looking for

  • Why there is no dependent req. passed from discontinued material ?

    Dear gurus, I set discotinue indicator=1, effective-out date and follow-up material. But, there is no dependent requirement passed from discontinued material material. That is I can't see the dependent requirement for the follow-up material. Anyone t

  • How can I delete all of my photos at once?

    I need more space on my iPhone (5, recently upgraded to iOS 8), so I need to delete all of my photos (which my Mac says have all been uploaded to iPhoto). When I try to use the "delete all" option in iPhoto, nothing actually happens. Thanks!

  • Satellite A200-23W: Windows Vista installation issue

    Hi.. I now that this subject is discussed many times before, but after trying a lot of the solutions of the forum and some of my one, I have reached a level that it makes no sense... First off all I would like to explain that what i do for a living i

  • How can I tell if my iPhone 4 is being tracked

    How Can I tell if my iPhone is being tracked

  • Selecting a column base on maximum value

    Hi , ColumnA  ColumnB   A               15   B                45   C                35   D                75   E                55 I need to get Column A based on Max and Min Value of Column B Here: I need to get the answer as D and A I could do this