1. FIND THE TRUE TAN WITHIN A CIRCLE

constant Pi=3.14159265359 --- Now in version 2.1

global function Sgn(atom x)
        if x>0 then
                return 1
        elseif x<0 then
                return -1
        else
                return 0
        end if
end function

global function arctan2(atom Y, atom X)
        return
))+(-Pi*2)*-(X<0))


WHERE X & Y ARE:

                                   +Y
                                     I
                                     I
                         -X -------------- +X
                                     I
                                     I
                                   -Y

Rod Damon
CAD-FAB ASSOCIATES
Montevallo, Al.

new topic     » topic index » view message » categorize

2. Re: FIND THE TRUE TAN WITHIN A CIRCLE

On Mon, 22 Mar 1999 RodDamon at AOL.COM wrote:

] constant Pi=3.14159265359 --- Now in version 2.1
]
] global function Sgn(atom x)
]         if x>0 then
]                 return 1
]         elsif x<0 then
]                 return -1
]         else
]                 return 0
]         end if
] end function
]
] global function arctan2(atom Y, atom X)
]         return
] abs(-arctan(X/(Y+(Y=0)))*-(Y!=0)-(Pi*.5)*Sgn(X)*-(Y=0)+Pi*-(Y<0)*(-(X>=0)+(X<0
] ))+(-Pi*2)*-(X<0))
]
] WHERE X & Y ARE:
]
]                                    +Y
]                                      I
]                                      I
]                          -X -------------- +X
]                                      I
]                                      I
]                                    -Y

I attempted to simplify your code, but something doesn't seem right...

global function arctan2(atom y, atom x)
  integer yeo, ylo, xlo -- conditions
  yeo = (y = 0) -- I hope the names are obvious enough :)
  ylo = (y < 0)
  xlo = (x < 0)

  return abs( -- you haven't defined abs() but I think we all know what
              -- it means :)... Are you sure all answers should be +ve?

    -- Calculation block:
    -- Result Section     * Condition Section

    + arctan( x/(y+yeo) ) * (1-yeo)          -- note the unary '+'

    + Sgn(X)*(Pi/2)       * yeo

    + Pi                  * ylo * (1-2*xlo)

    + 2*Pi                * xlo

  )
end function

I can cope with obfuscated shortest-Euphoria code, in fact I'm a great
lover of it (I did similar things in Commodore BASIC many moons ago) but
not at the level you showed in your example! Ooh, my head hurts :)

Carl

PS Nice work by the way...

--
Carl R White -- cyrek- at -bigfoot.com -- http://www.bigfoot.com/~cyrek
 aka Cyrek   --    No hyphens :)    --       Bigfoot URL Alias

new topic     » goto parent     » topic index » view message » categorize

3. Re: FIND THE TRUE TAN WITHIN A CIRCLE

--part0_922207581_boundary
Content-ID: <0_922207581 at inet_out.mail.aol.com.1>
Content-type: text/plain; charset=US-ASCII

Carl:

       Yes, I want the + Vector of my arctan2 which is called Arctan()
in the attached files.  I mainly use this function to find the direction
of travel of a line or the start & stop angles of an arc.

        I use many of your routines and also Colin Taylor's routines.
The best way to explain this was with demo programs & includes.
I apologize for attaching these to anyone not interested in math.

        I use Boolean logic in many of my functions and if you don't understand
Boolean logic, it gets hard to explain.

        I mainly write commercial programs using Euphoria for complicated ACAD
programs requiring extensive math which is not suited for ACAS LISP
programming.

ROD DAMON
CAD-FAB ASSOCIATES
MONTEVALLO, AL. (USA)

--part0_922207581_boundary
Content-ID: <0_922207581 at inet_out.mail.aol.com.2>
Content-type: application/zip;
        name="CIRCLE.ZIP"

new topic     » goto parent     » topic index » view message » categorize

4. Re: FIND THE TRUE TAN WITHIN A CIRCLE

On Tue, 23 Mar 1999 RodDamon at AOL.COM wrote:

]         I use Boolean logic in many of my functions and if you don't
] understand Boolean logic, it gets hard to explain.

Boolean logic is fairly simple (AFA I'm concerned). I believe my
translation of your arctan2() showed that. Granted, I reversed a couple of
signs (and always reversed twice to undo the sign reversal), and used a
few sneaky tricks like "1-yeo" rather than "not yeo", but the logic is
still there. (I hope - see next comment)

]         I mainly write commercial programs using Euphoria for
] complicated ACAD programs requiring extensive math which is not suited
] for ACAS LISP programming.

Eep! You might just want to double check my routines if you're going
to use them in commercial software. I'm not saying they're wrong, but
they're probably provably imperfect... :)

Thanks,
Carl

--
Carl R White -- cyrek- at -bigfoot.com -- http://www.bigfoot.com/~cyrek
 aka Cyrek   --    No hyphens :)    --       Bigfoot URL Alias

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu