Results 1 to 8 of 8

Math Help - Need to control a curve..

  1. #1
    Newbie
    Joined
    May 2009
    Posts
    5

    Need to control a curve..

    I'm afraid I'm a bit of a math cosumer more than a mathametician & I would be very indepted if someone could show me a formula.

    I'm working on a computer-graphics application and I need to fade a value non-linearaly over the range of 0 to 1. Where Y = 0 at 0, and Y = 0 at 1, and Y = 1 somewhere in between. Beyond X= 0 and X= 1 it will be clipped, so I don't care what Y is beyond those values.

    The graph in this image is Y = sin(x^K * 3.14156) which has the basic shape I'm after, but would like more control over the slopes on the left and right of the peak, and the placement of the peak. (despite the values on the X axis, the interval of X is 0 - 1.
    All the best,
    Byron

    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Nov 2008
    From
    France
    Posts
    1,458
    Hi

    The derivative of Y = \sin(\pi\:x^k) is Y = k\:\pi\:x^{k-1}\:\cos(\pi\:x^k)

    The derivative is equal to 0 for x=0 and \pi\:x^k = \frac{\pi}{2}

    If you need to control the peak, for instance have the peak at a given value x_0 then you have to chose k such that \pi\:x_0^k = \frac{\pi}{2} \Rightarrow x_0^k = \frac{1}{2} \Rightarrow k\:\ln(x_0) = -\ln(2) \Rightarrow k = -\frac{\ln(2)}{\ln(x_0)}
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor Calculus26's Avatar
    Joined
    Mar 2009
    From
    Florida
    Posts
    1,271
    I can help a little

    The placement of the peak is detrmined by k in fact the peak occurs

    at 1/[2^(1/k]

    So to put the peak at say x= a solve 1/[2^(1/k] = a

    this yields k = -ln(2)/ln(a)


    I guess I'm a little slow here
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    May 2009
    Posts
    5

    Need to control a curve

    Many thanks! makes perfect sense once I look at it. The curve will start at 0 and peak when x^K*pi = radians(90) won't it, so I'd just adjust K to determine at what value of X I hit .5 pi.

    Is there anything (simple) you can see that can modify the slopes on either side or will I have to investigate bezier curves & the like?

    ( this is going into a real time shader in a video game, so it needs to be relatively computationaly inexpensive )

    Many thanks again,
    Byron
    Last edited by DrJBN; May 7th 2009 at 11:21 AM. Reason: Added info
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor
    Joined
    Nov 2008
    From
    France
    Posts
    1,458
    Can you be more precise about the slopes you want to control ?
    On the left side of the peak there is obviously an inflection point. The slope at this point is the maximum.
    On the right side the slope seems to be maximum (absolute value) at the end.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    May 2009
    Posts
    5

    Need to control a curve..

    Yes, if you look at the picture here I'd ideally want near-independent control of the peak and the deflection of the curve from each of the black lines on the up & down side (e.g., be able to move the red curve up to be the orange etc..)

    Best
    Byron

    Follow Math Help Forum on Facebook and Google+

  7. #7
    MHF Contributor
    Joined
    Nov 2008
    From
    France
    Posts
    1,458
    If I have well understood you would like to have the peak at the same place (not moving) and move the the red curve up to the orange one.

    This is not feasible with a simple function like Y = \sin(\pi\:x^k) because as we saw before the position of the peak determines the value of k and therefore Y function.

    There should be something more like Y = f(x)\: \sin(\pi\:x^k)
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    May 2009
    Posts
    5
    Quote Originally Posted by running-gag View Post
    If I have well understood you would like to have the peak at the same place (not moving) and move the the red curve up to the orange one.

    This is not feasible with a simple function like Y = \sin(\pi\:x^k) because as we saw before the position of the peak determines the value of k and therefore Y function.

    There should be something more like Y = f(x)\: \sin(\pi\:x^k)
    Right, I'm hoping there exists some relatively computationally inexpensive function with three free parameters to control A: the peak, B: the inflection left of peak and C: inflection right of peak.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Quality Control?
    Posted in the Advanced Statistics Forum
    Replies: 8
    Last Post: May 4th 2011, 01:31 PM
  2. Control chart
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: April 11th 2010, 09:08 AM
  3. control limit?
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: October 1st 2009, 11:19 PM
  4. Replies: 0
    Last Post: April 6th 2009, 09:02 PM
  5. Nonlinear control
    Posted in the Advanced Applied Math Forum
    Replies: 2
    Last Post: December 2nd 2006, 01:46 AM

Search Tags


/mathhelpforum @mathhelpforum