Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 3617 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have copied the following formula from excel into my calculation field:

DEGREES(ATAN2(COS(RADIANS(S2)),COS(RADIANS(U2))*SIN(RADIANS(S2)))

Since FM doesn't recognize the function "ATAN2", I added a custom function as follows:

Let ( [

a =

If ( x > 0 ; Atan( y / x ) ;

If ( x < 0 ; Pi - Atan( -y / x ) ;

Pi / 2 * Sign ( y ) ) );

result = Mod( a; 2 * Pi)

];

result

)

based on the following source: http://www.briandunning.com/cf/502 but unfortunately the function doesn't seem to be working properly, or at least the same way as it does in excel.

Can anyone provide the custom function script equivalent to the "ATAN2" function in excel?

Posted

Seems to work for single positive digits but the actual y and x values I need to process are:

ATAN2(0.72,-0.63)

Excel gives me: -0.72

but FM gives me 2.29

  • 2 years later...
  • 1 month later...
Posted

1. You need Filemaker Pro Advanced to add custom functions.

2. File>Manage>Custom Functions

3. New

4. Add "ATAN2" in Function Name field

5. Function parameters type "y", click the plus sign, then type "x", click the plus sign

6. Copy and paste this code into the "New Function" box:

 

Let ( [

a = 
Case ( x > 0 ; Atan( y / x ) ;
x < 0 ; If ( y ≥ 0 ; Pi + Atan ( y / x) ; -Pi + Atan ( y / x)) ;
x = 0 ; If ( y > 0 ; Pi / 2 ; If ( y < 0 ; -Pi / 2 ; 0) )) ;
result =a
];
result
)

 

Source for this code is http://www.briandunning.com/cf/502but make sure you scroll to the discussion box where he modifies the original code shown above. Worked for me.

Posted

6. Copy and paste this code into the "New Function" box:

 

Let ( [

a = 

Case ( x > 0 ; Atan( y / x ) ;

x < 0 ; If ( y ≥ 0 ; Pi + Atan ( y / x) ; -Pi + Atan ( y / x)) ;

x = 0 ; If ( y > 0 ; Pi / 2 ; If ( y < 0 ; -Pi / 2 ; 0) )) ;

result =a

];

result

)

 

 

If you scroll back to post #2 of this thread ...

This topic is 3617 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.