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

# Re: [FEMM] Problems with math functions

- To: FEMM mailing list <femm@list.foster-miller.net>
- Subject: Re: [FEMM] Problems with math functions
- From: David Meeker <dmeeker@ieee.org>
- Date: Mon, 23 Feb 2004 21:58:51 -0500
- In-reply-to: <web-63545223@california.com>
- List-archive: <http://femm.foster-miller.net/pipermail/femm>
- List-help: <mailto:femm-request@list.foster-miller.net?subject=help>
- List-id: FEMM mailing list <femm.list.foster-miller.net>
- List-post: <mailto:femm@list.foster-miller.net>
- List-subscribe: <http://femm.foster-miller.net/mailman/listinfo/femm>, <mailto:femm-request@list.foster-miller.net?subject=subscribe>
- List-unsubscribe: <http://femm.foster-miller.net/mailman/listinfo/femm>, <mailto:femm-request@list.foster-miller.net?subject=unsubscribe>
- References: <web-63545223@california.com>
- Reply-to: FEMM mailing list <femm@list.foster-miller.net>
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 MultiZilla/1.6.0.0e

`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@yahoo.com> 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@list.foster-miller.net
>     http://femm.foster-miller.net/mailman/listinfo/femm

> ``

``

- References:
  - Re: [FEMM] Problems with math functions
    - From: "robert Macy" <macy@california.com>

- Prev by Date: Re: [FEMM] Problems with math functions
- Next by Date: [FEMM] problem on plotting flux densityalong a curvature in the middle of airgap
- Previous by thread: Re: [FEMM] Problems with math functions
- Next by thread: [FEMM] FEMM features request
- Index(es):
  - Date
  - Thread