Results 1 to 6 of 6

Thread: Math formula (sin)

  1. #1
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Math formula (sin)

    Hi,
    I am working on a PHP/MySQL script where i need to apply a math formula.
    Code:
    sin(a) = m(V - b)
    Here m and b are static values, which i already have, V is coming from a sensor live, so i need to calculate 'a' here.
    something like:
    Code:
    a = sin(m(V - b))
    But i am not sure, that how to move sin to other side and leave just 'a' on the left side.

    Any ideas about this math formula.
    Thanks.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  2. #2
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,710
    Blog Entries
    1

    Default Re: Math formula (sin)

    From memory, I think you want the arcsine function:

    a=asin(m(V - b))

  3. #3
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: Math formula (sin)

    Thanks.
    As i did like this way, which i know is wrong somehow.
    Code:
    $a_x = sin(0.062763 * ($ch410 - (-0.19564)));
    $a_y = sin(0.062763 * ($ch411 - (-0.19564)));
    The above give the output:

    x: 2.52651224568
    y: -1.27401076136
    Now if i put the asin function:
    Code:
    $a_x = asin(0.062763 * ($ch410 - (-0.19564)));
    $a_y = asin(0.062763 * ($ch411 - (-0.19564)));
    The output is:
    x: 2.55217155313
    y: -1.27724895412
    Which is also wrong. The output in this case would be:
    x = 10
    y = -5
    In this case V is, which is $ch410 and $ch411:
    x: 2.570
    y: -1.585
    I am sure, before putting the values in the formula, have to simply the formula 1st, then put values, but the hard part is that for me, to simply the formula 1st.

    Any ideas?
    Last edited by mmarif4u; 22-Oct-2009 at 02:03. Reason: Adding..
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Math formula (sin)

    Remember that these trig functions usually expect input and generate output in radians, not degrees.

  5. #5
    Join Date
    Sep 2008
    Location
    Earl Shilton UK
    Posts
    298

    Default Re: Math formula (sin)

    Agree with ken_yap. It's arcsine (sin^-1) you need - working here:

    a = sin(m(V - b))

    sin^-1 (a) = sin^-1 (sin(m(V-b)))

    sin^-1 (a) = m(V-b)

    And yeah, you need to use radians, not degrees. Convert degrees to radians like this:

    radians = degrees * (pi/180).

    I'd use the math constant pi in php rather than use an approximation.
    Happily using Linux since 1998
    Share & Enjoy

  6. #6
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: Math formula (sin)

    Thanks guys for all your support and help.
    That rad2deg did the job.

    PHP Code:
    $a_x asin($m * ($ch410 $b));
    $a_y asin($m * ($ch411 $b));

    echo 
    rad2deg($a_x).'<br />';
    echo 
    rad2deg($a_y).'<br />'
    Thanks again Kenyap and weighty_foe and deano_ferrari.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

Posting Permissions

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