Math expressions

This forum is currently in read-only mode.
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • Where can I find the math that's being uses behind the system math expressions? I need to convert a few of them to work with my 3D coordinates system like distance between or w/e (those expressions that use xy only).

    And 5 point lerp would be nice for half circle math so I don't have to toy with 5 lerps together to make a simple half circle or w/e for my collisions.

  • Make functions for your needs with the Function object?

  • I'm sorry if I'm not clear, I wanted the real math for those expressions as if it was written down on pen and paper & how it was written with C++ so I can do a better job of converting.

    Might want to take a look at cubic()

    hat about the 5th value? cubic abcd cubic bcde will do fine enough. thx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could also try looking at the implementation of the system expressions in System.cpp:

    http://construct.svn.sourceforge.net/vi ... iew=markup

    The ExpRoutineTable array at line 436 maps the expression string (eg. "lerp") to the routine (&SystemObject::eLerp) - if you then search for SystemObject::eLerp (without ampersand) you'll find the implementation:

     3887 long SystemObject::eLerp(LPVAL theParams, ExpReturn& ret)
     3888 {
     3889 	// Calculate linear interpolation:
     3890 	// lerp(a, b, x) = a + x(b - a)
     3891 	double a = theParams[0].GetDouble();
     3892 	double b = theParams[1].GetDouble();
     3893 	double x = theParams[2].GetDouble();
     3894 
     3895 	return ret = Lerp(a, b, x);
     3896 }
    [/code:1y4dyv82]
    
    You can use that to find the implementation of any system expression.  Does that help?
  • Where can I find the math that's being uses behind the system math expressions? I need to convert a few of them to work with my 3D coordinates system like distance between or w/e (those expressions that use xy only).

    And 5 point lerp would be nice for half circle math so I don't have to toy with 5 lerps together to make a simple half circle or w/e for my collisions.

    distance can work with any two dimensions, x,y x,z y,z etc.

    3D distance is just: sqrt(?X^2+?Y^2+?Z^2)

    angle(,,,,) doesnt need to be 3d.

    what excactly is half circle math, and why do you need beziers to draw one? sin&cos is much better suited, and infact its extremely faster work wise and power wise. what are you trying to do because i cant help but think your making things harder for yourself the way your going about things right now

  • Does that help?

    es, it does. Thank you.

    QuaziGNRLnose I might send a PM regarding some of your questions.

    I have a question. What uses more CPU? Adding abs(x1 - x2) + (repeat for y,z) or using the square root?

  • I have a question. What uses more CPU? Adding abs(x1 - x2) + (repeat for y,z) or using the square root?

    The square root calculation, definitely. Finding the square root of a number requires the use of multiplication and division, both of which are slower than addition and subtraction.

  • In the context of Construct, the difference between these two calculations is negligable (although linkman is right that the square root is technically more intensive). The overhead of the events probably measures 100x or 1000x the performance difference between two such low level functions. The only thing which matters is: is it fast enough?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)