Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Maths function help

ClintonbClintonb Posts: 1Member
I've created an app that uses the maths function (i'm a first time user). The two functions i've created are to convert from x to y and then the reverse of y to x.

function xtoy(x:real;center:tpoint;rad:real):real;

var
answer:real;

begin;
answer:=x;
answer:=centerpoint.y-answer;
answer:=answer/(rad*0.5);
answer:=math.Power(2.718281828459045,answer);
answer:=math.ArcSin( (answer-1)/(answer+1) );
answer:=answer*180/3.141592654;

result:=answer;
end;

function ytox(y:double;center:tpoint;rad:double):double;

var
answer:double;
checkout:integer;
min,diff:real;

begin;
answer:=y;

answer:=answer*((22/7)/180);

answer:=math.LogN(2.718281828459045,(1+Sin(answer))/ (1-sin(answer)));
answer:=answer*0.5*rad;
answer:=centerpoint.y-answer;

result:=answer;
end;


These functions are the reverse of each other and technically, if you were to use them in xty(ytox(10,1,1),1,1) should return the answer 10 but when centerpoint and rad become larger in value, there is an increasing differnece between what i should get and what i do. ie ytox(10,100000,100000)=4 and xtoy(4,100000,100000)=21? Obviously they are approximately opposite but deviate at large values but i've looked at this 100 times and i can't see the error. If anything jumps out as obviously wrong, could you please drop me a message.

Thanks in advance
Clinton
Sign In or Register to comment.