Shop OBEX P1 Docs P2 Docs Learn Events
inverse trig functions — Parallax Forums

inverse trig functions

ArchiverArchiver Posts: 46,084
edited 2001-02-12 17:55 in General Discussion
Currently I am working on a project to simulate sunrise and sunset for a
given date and geographical coordinates using a STAMP 2. My main source of
problems is that most of the algorithms available require inverse trig
functions(atan, asin, acos) to work properly. The only way I can think of
implementing them is to have a table of values stored for every possible
angle, but I don't really want to use that much space.

I would appreciate any feedback you could give me in this regaurd. If
someone has the source code for computing inverse trig functions or has
made a similiar program to compute daylight hours on a stamp, I would love
to see it.

May the Force of God be with you,
Kevin Womack
___,
,____
__--~~~~ ~~---,_
,-' __,--,_ `\,___,-,__
,-' __/'/-~~~\ ` ` . ' , | `~~\
_/` _/~~ '~~ \,_\_ O / ' '~_/' `\
/' ' =-'~~ _ / ~ /' `\
_/' /~ ,--,____,
|,_,-,_ `\
_,/' ' ,-' _ `~'
'~~~~~-- `~~~~\ |
,-' /~ ' ,-~~~ _, ,-=~~~~~~~~~~~~'| |
~ .' ' , ' /~` |/
/' ,/' _/~'
, / /` _/~ "But those who hope in the
/~ / /` /'Lord will renew their strength.
.' /' They will soar on wings like
/' . /' eagles; they will run and not grow
` /' | weary, they will walk and not be
' faint." - Isaiah 40:31

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-02-12 16:09
    make table with calculation for every 2 or 3 degrees - then interpolate
    between table entries
    make use of symmetry - should get useful results with only 40 or 50 table
    entries

    richard


    Original Message
    From: "Kevin Womack" <jedi@m...>
    To: <basicstamps@yahoogroups.com>
    Sent: Monday, February 12, 2001 9:46 AM
    Subject: [noparse][[/noparse]basicstamps] inverse trig functions


    > Currently I am working on a project to simulate sunrise and sunset for a
    > given date and geographical coordinates using a STAMP 2. My main source
    of
    > problems is that most of the algorithms available require inverse trig
    > functions(atan, asin, acos) to work properly. The only way I can think of
    > implementing them is to have a table of values stored for every possible
    > angle, but I don't really want to use that much space.
    >
    > I would appreciate any feedback you could give me in this regaurd. If
    > someone has the source code for computing inverse trig functions or has
    > made a similiar program to compute daylight hours on a stamp, I would love
    > to see it.
    >
    > May the Force of God be with you,
    > Kevin Womack
    > ___,
    ,____
    > __--~~~~ ~~---,_
    > ,-' __,--,_ `\,___,-,__
    > ,-' __/'/-~~~\ ` ` . ' , | `~~\
    > _/` _/~~ '~~ \,_\_ O / ' '~_/' `\
    > /' ' =-'~~ _ / ~ /' `\
    > _/' /~ ,--,____,
    |,_,-,_
    `\
    > _,/' ' ,-' _ `~'
    '~~~~~-- `~~~~\
    |
    > ,-' /~ ' ,-~~~ _, ,-=~~~~~~~~~~~~'|
    |
    > ~ .' ' , ' /~` |/
    > /' ,/' _/~'
    > , / /` _/~ "But those who hope in
    the
    > /~ / /` /'Lord will renew their
    strength.
    > .' /' They will soar on wings like
    > /' . /' eagles; they will run and not
    grow
    > ` /' | weary, they will walk and not be
    > ' faint." - Isaiah 40:31
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-02-12 17:05
    A table with interpolation would do it in less entries. If you want real
    floating point, check out our PAK-II --
    http://www.al-williams.com/awce/pak1.htm (page for PAK1 and PAK2, but the
    PAK2 is the one with trig).

    Al Williams
    AWC


    >
    Original Message
    > From: Kevin Womack [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IWSqXjhk1OfKhotBqwTK1LLkr-BkXVQgB6ROobvjPfux20zt2zl3dTTPbdEV2kz1D8nFOhZyDBxZGhId]jedi@m...[/url
    > Sent: Monday, February 12, 2001 9:47 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] inverse trig functions
    >
    >
    > Currently I am working on a project to simulate sunrise and sunset for a
    > given date and geographical coordinates using a STAMP 2. My main
    > source of
    > problems is that most of the algorithms available require inverse trig
    > functions(atan, asin, acos) to work properly. The only way I can think of
    > implementing them is to have a table of values stored for every possible
    > angle, but I don't really want to use that much space.
    >
    > I would appreciate any feedback you could give me in this regaurd. If
    > someone has the source code for computing inverse trig functions or has
    > made a similiar program to compute daylight hours on a stamp, I would love
    > to see it.
    >
    > May the Force of God be with you,
    > Kevin Womack
    > ___,
    ,____
    > __--~~~~ ~~---,_
    > ,-' __,--,_ `\,___,-,__
    > ,-' __/'/-~~~\ ` ` . ' , | `~~\
    > _/` _/~~ '~~ \,_\_ O / ' '~_/' `\
    > /' ' =-'~~ _ / ~ /' `\
    > _/' /~
    > ,--,____,
    |,_,-,_ `\
    > _,/' ' ,-' _ `~'
    '~~~~~--
    > `~~~~\ |
    > ,-' /~ ' ,-~~~ _,
    > ,-=~~~~~~~~~~~~'| |
    > ~ .' ' , ' /~` |/
    > /' ,/' _/~'
    > , / /` _/~ "But those who
    > hope in the
    > /~ / /` /'Lord will renew
    > their strength.
    > .' /' They will soar on wings like
    > /' . /' eagles; they will run
    > and not grow
    > ` /' | weary, they will walk and not be
    > ' faint." - Isaiah 40:31
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-02-12 17:55
    Kevin,

    As the others said, a table with interpolation is the quick and easy
    way, but there are other methods. The way in which computers (BS2 or
    your desktop PC) compute complex functions like sin, arcsin, etc., is
    through an approximation method known as finite Taylor series
    polynomials. To any desired degree of precision, there is a
    polynomial function (i.e., f(x) = a + bx + c x^2 + d x^3) that is
    guaranteed to be within whatever your accuracy limit is of sin(x).
    This is likely to also be true for arcsin, arctan, etc., although I
    don't remember off the top of my head and I would need to do the math
    to check it out. If you feel that this is for some reason neccessary
    for your application, write back and I'll help you through the math.

    -Doug McClean
    jxm156@p... or IDiggles@a...
    (woohoo, I finally get to _answer_ a question on this group, I knew
    it would happen eventually...)

    --- In basicstamps@y..., Kevin Womack <jedi@m...> wrote:
    > Currently I am working on a project to simulate sunrise and sunset
    for a
    > given date and geographical coordinates using a STAMP 2. My main
    source of
    > problems is that most of the algorithms available require inverse
    trig
    > functions(atan, asin, acos) to work properly. The only way I can
    think of
    > implementing them is to have a table of values stored for every
    possible
    > angle, but I don't really want to use that much space.
    >
    > I would appreciate any feedback you could give me in this regaurd.
    If
    > someone has the source code for computing inverse trig functions or
    has
    > made a similiar program to compute daylight hours on a stamp, I
    would love
    > to see it.
    >
    > May the Force of God be with you,
    > Kevin Womack
    > ___,
    ,____
    > __--~~~~ ~~---,_
    > ,-' __,--,_ `\,___,-,__
    > ,-' __/'/-~~~\ ` ` . ' , |
    `~~\
    > _/` _/~~ '~~ \,_\_
    O / ' '~_/' `\
    > /' ' =-'~~ _ /
    ~ /' `\
    > _/' /~ ,--,____,
    |,_,-
    ,_ `\
    > _,/' ' ,-' _ `~'
    '~~~~~--
    `~~~~\ |
    > ,-' /~ ' ,-~~~ _, ,-
    =~~~~~~~~~~~~'| |
    >
    ~ .' ' , ' /~`
    |/
    > /' ,/' _/~'
    > , / /` _/~ "But those who
    hope in the
    > /~ / /` /'Lord will renew their
    strength.
    > .' /' They will soar on
    wings like
    > /' . /' eagles; they will run
    and not grow
    > ` /' | weary, they will walk and
    not be
    > ' faint." - Isaiah 40:31
Sign In or Register to comment.