User Tag List

Results 1 to 5 of 5

Thread: Maths Problem - Line Function

  1. #1
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Maths Problem - Line Function

    I need to draw a very particular kind of line (approximating it using a logarithmic curve is not going to be sufficient). Any help would be very gratefully appreciated!



    The line will be straight from 0,0 to Point_A.

    It will be a curve from Point_A to 1,1.
    The gradient of this curved section will initally be the same as the gradient of the straight section, but will decrease gradually (linearly), reaching 0 when x=1.

    Point_A will always have X and Y coordinates in the range 0 to 1.
    Point_A will also always be above the straight line from 0,0 to 1,1 (ie. in the half of the chart shaded darker), in case that makes a difference.

    For any value of X between 0 and 1, I need a formula to calculate Y.
    In fact, it really just needs to be for any vaue of X between Ax and 1, since the straight section is relatively trivial.




    Here's what I've tried so far...
    I'm extending the line from 0,0 to A, to find the value of Y when X is 1 (see the pink line).
    When X=1, Y = Ay / Ax
    eg. Y = 0.5 / 0.25 = 2

    The pink straight line is always above the ideal curved line, but by how much? (see Line_D)
    I know that when X=1, the difference between the Y values of my straight line and my ideal curved line is Ay / Ax (which is 2 in this example) .
    At X=Ax, the difference is 0.
    For any given point between them, the difference will be somewhere between - but it doesn't seem to be a linear relationship.

    For any given point on the line (Point_P), I'm finding Px - Ax (Line_B), and expressing it as a proportion of 1 - Ax (Line_C).
    B = (Px - Ax) / (1 - Ax)

    When Px=Ax, B=0.
    When Px=1, B=1.

    If I raise B to the power of 1.5, and subtract that from the straightline formula, I get the correct result here - but it only holds true for this example (I only arrived at the value of 1.5 through trial and error).
    eg. If X=0.5,
    B = (0.5 - 0.25) / (1 - 0.25) = 0.33333
    B ^ 1.5 = 0.19245
    Y = (0.5 * 0.5 / 0.25) - 0.19245 = 0.80755

    So, how on Earth do I calculate the right exponent to use for any given position of Point_A?
    Or am I doing something totally wrong to begin with?

  2. #2
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCiOS Export ModuleSWF Export ModuleFirefly 3D Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    fnkycoldmadeanr's Avatar
    Join Date
    Jul 2017
    Location
    Melbourne, Australia
    Posts
    166
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Not sure how much help I’ll be Muddy
    But I was thinking you might be able to simplify things a bit
    Attachment 28390

    Have you been using desmos?

    Also this video is a pretty good watch
    3:40:00 ish I think
    https://youtu.be/yg6h4XQqPNQ

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Thanks - that's an interesting link
    It turns out that what I wanted is actually physically impossible. There's precisely one location of Point_A where it is possible to reach an end point of 1,1 and gradient of zero, using a constant change of angle - in every other case, it's possible to get either the correct end point, or the correct end gradient, but not both.

    I asked the same question on a couple of maths forums, and a user by the name of Dr.Peterson ( freemathhelp.com ) was kind enough to provide me with a solution that I think will be good enough for my purposes: https://www.desmos.com/calculator/ehtele1rsf

    That was actually the first time I've come across Desmos, but it seems pretty useful, so I may look into it a bit more. I also like Wolfram Alpha for simplifying complicated formulas, although I'm slightly torn on whether that's even a good idea (a simpler formula is neater and faster, but if I come back to it months later, it won't be obvious how I derived it).

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,398
    Mentioned
    113 Post(s)
    Tagged
    0 Thread(s)
    We live in dark times when the Fusion guru himself needs to ask for help!

    Sounds like you've got what you need, but but I thought I'd also mention a program I've been using myself recently called Curve Expert. I use it to create Polynomial curves from data points, and it's pretty good. It can also create many other types of curves - Bleasdale curves, tension splines, DR-Multistage-2-Zerobackground, and all sorts of other gobbledygook - so perhaps it can do the 'hockey stick' type that you're after.

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Haha, thanks.
    That looks interesting - probably overkill for my little curve. I think the solution I have now will work, but also, I'm beginning to think that even just approximating a curve using 2 or 3 straight line segments will be good enough, and might better fit the general retro aesthetic.
    It was going to be for a 7-day-roguelike (7drl) gamejam entrant, but I'm never going to finish it in time now anyway - I spent way too long on the most pointless things! I should probably try to finish it off though...

Similar Threads

  1. I created a line of sight function that works with multiple enemies.
    By PlasmaVoid in forum Guides, Tutorials, Examples, Widgets
    Replies: 3
    Last Post: 31st December 2015, 03:07 AM
  2. Fast Function Problem
    By Orogenesis in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 8th May 2014, 03:20 PM
  3. 360 Degree Maths Problem
    By DaveC in forum Fusion 2.5
    Replies: 5
    Last Post: 16th February 2014, 08:42 PM
  4. Function Eggtimer problem // Power Function for MMF2 Android?
    By ogrgkyle in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th May 2013, 03:17 AM
  5. Maths Problem
    By MuddyMole in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 11th April 2009, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •