[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [FEMM] Problems with math functions



Like Robert implied, the trick here is that Lua expects all trig functions to use degrees instead of radians (e.g the atan and atan2 return angles in degrees and sin, cos, tan take angles in degrees).

atan2() seems to work OK for me--remember that it takes 2 arguments. For example, if one pastes the line:

print(atan(1),atan2(-1,-1))

into the Lua console window and evaluates it, the line:

--> 45 -135

gets printed in the output window. The results are the correct angles for each case, just returned in degrees. This should work OK with any version of femm that supports lua scripting.

At any rate, if the functions in terms of degrees are too irritating, it's easy enough to define versions that work with radians:

function arctan(x)
   return atan(x)*PI/180
end
function arctan2(x,y)
   return atan2(x,y)*PI/180
end
function sine(x)
   return sin(x*180/PI)
end
function cosine(x)
   return cos(x*180/PI)
end
function tangent(x)
   return tan(x*180/PI)
end

robert Macy wrote:

My FEMM 3.3, build 24May03, under Windows 98 runs lua
script using atan() with no problem, returning answers in
degrees.

However, there is no atan2() that seems to work at all,
generates all kinds of error msgs.


- Robert -


On Mon, 23 Feb 2004 12:51:46 -0800 (PST)
Daniyarov Talgat <tdaniyar@xxxxxxxxx> wrote:


Hi,
I use FEMM 3.3, Build 17Aug 2003 under Windows 2000.
In my Lua-Script for FEMM I can not acess "atan"
(invers tangent)or "atan2" (the same function with
different input) functions which are the part of
LUA Math package. The output of both is some
garbage though the script is runnung without any
error message. I checked that it is not an input
arguments problem. Any suggestion to overcome this
problem?

Thanks in Advance,

Talgat



_______________________________________________
FEMM mailing list
FEMM@xxxxxxxxxxxxxxxxxxxxxx
http://femm.foster-miller.net/mailman/listinfo/femm