Announcement

Collapse
No announcement yet.

Calculating an Angle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating an Angle

    Hi,

    Can someone help me refresh my trigonometry on calculating an angle?

    I am using the general formula [see below] but I do not get the expected angles for known values.

    myAngle = 180*Math.atan2(x,y)/Math.PI;

    for x=0 or y=0 or x=y results are as expected 0,90,45.
    but for x=2y or y=2x, where we know angles are 60 or 30 degrees the result are off [63.43 annd 26.56 respectevely].

    Can someone explain why and what should I do to get the correct result?

    Thank you.
    Mihai Buta

  • #2
    Mihai,

    Alexis and Kobus worked on this script and it may contain some valuable info: http://forum.esignalcentral.com/atta...=&postid=92018

    I'm not a programming wizard and may be out of my league here, but it could be that offsetting(-1) either x or y (depending on which designation you have for the adjacent and opposite sides) may give you what you need!?

    Noticed that 30-60-90 angle ratio triangles compute fine using Math.acos and that arctangent function will always return 63.x degrees when the x,y ratio is 0.5.

    Best regards (noroc),

    Russ
    --FOREX--

    Comment


    • #3
      Russ,

      Thank you for trying to help.

      1. The [-1] in the efs you refer to is not the previous bar, but only to calculate the ratio of the two MA's.
      2. At this point I am convinced that efs implementation of the Java for Math object has errors and that is why the results are so far off.
      Java, by definition [see the link below] does not guarratee "exact calculation" but 5% error is way too much.

      If I am wrong, I invite efs specialists to tell us where we make the error and how to correct it.

      Final note: I have tried diferent values for most math functions [sin, cos, tan, tan2] and I am 99% convinced that the efs implementation of these functions has bugs.
      For example:
      sin(4/4) = .47 [not .5]
      sin(4/2) = .9 but
      sin(3/2) = .99 and should lower, and
      sin(6/2) or higher turn negative instead of approaching 1.

      Again, I hope I do something very stupid here, but I believe eSignal needs to review the implementation and/or offer an explanation.

      Thank you.


      http://java.sun.com/j2se/1.5.0/docs/...l#atan(double)
      Last edited by mbuta; 03-03-2007, 11:01 AM.
      Mihai Buta

      Comment


      • #4
        I talked with my grandson [5th grader] and he clarified the issue for me.

        Thank you, you can ignore this post.
        Last edited by mbuta; 03-03-2007, 04:28 PM.
        Mihai Buta

        Comment

        Working...
        X