Support » Plugin: Calculated Fields Form » Finding hypotenuse

  • Resolved EliteWebServices

    (@elitewebservices)


    Couple questions…

    1. I am going to need to be able to add data to my wordpress database which is getting displayed in the CFF formulas. What version of the plugin will I need to purchase?

    2. I’m having quite an issue using the sin, cos and tan functions. At the url given above I am using the following code but am getting the wrong results. Any assistance would be greatly appreciated.

    (function(){ if(0<fieldname6 && 0<fieldname2) return PREC(SQRT(POW(fieldname6,2) + POW(fieldname2,2)),2);

    if(0<fieldname8 && 0<fieldname6) return prec(fieldname6 / sin(90-fieldname8),2);

    if(0<fieldname2 && 0<fieldname8) return prec(fieldname2 / cos(fieldname8),2); })()

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @elitewebservices,

    If you want to store the submitted data into your own database’s tables, you will need at least the Developer version of the plugin, and edit the “cp_calculatedfieldsf_insert_in_database.php” file for entering the database connection data, and the insertion queries. More information in the following link:

    https://cff.dwbooster.com/documentation#third-party-database

    Concerning to the equation, you are forgetting something, in javascript the operations: cos, sin, tan, etc. are calculated with angles in Radians. If the angles are entered in degree, you should convert them to radians first, as follows:

    
    (function(){ 
    
    if(0<fieldname6 && 0<fieldname2) return PREC(SQRT(POW(fieldname6,2) + POW(fieldname2,2)),2);
    
    if(0<fieldname8 && 0<fieldname6) return prec(fieldname6 / sin((90-fieldname8)*PI/180),2);
    
    if(0<fieldname2 && 0<fieldname8) return prec(fieldname2 / cos(fieldname8*PI/180),2); 
    
    })()
    

    Best regards.

    Thank you for the reminder re: radians.

    The second line of code still doesn’t return the correct result. I use a 3,4,5 triangle for testing when Side B = 3 and Angle = 36.87 the result should be 5 but its returning 3.75?

    Plugin Author codepeople

    (@codepeople)

    Hello @elitewebservices,

    The error is in your maths, the correct mathematical formula is: h = b/sin(Angle) and not b/sin(90-angle)

    So, the piece of code should be:

    if(0<fieldname8 && 0<fieldname6) return prec(fieldname6 / sin(fieldname8*PI/180),2);

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need additional support implementing your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

    Thank you again for your expertise in setting up these formulas. I will keep your offer in mind as I move forward with this project. I’m hoping to get a full rundown on the customers expectations tomorrow and will most likely need you assistance (as I’m not a math guru). I will contact you through the link you provided for those items.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Finding hypotenuse’ is closed to new replies.