TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Water Bear on January 12, 2004, 09:53:02 PM

Title: upside down...
Post by: Water Bear on January 12, 2004, 09:53:02 PM
Can anyone tell me if this is a viable function..it doesn't seem to work properly.
Or maybe you've got something better..
Code: [Select]
(defun ArcCos (num)
  (if (zerop num)
    (* pi 0.5)
    (atan (sqrt (- 1.0 (* num num))) num)
    )
  )

I've got a known slope and a known run....need to calc the rise
Title: upside down...
Post by: Keith™ on January 12, 2004, 11:05:07 PM
Well, since you are only providing a single number to the program......

Which value is NUM? Perhaps cosine?

I will go with that conjecture .... that being said ...

ArcCosine = ArcTangent √(1 - cosine˛) cosine

Of course this will only return the angles where:

0 < ArcCosine < pi

So.....

If that is what you are asking,  then as long as you are not expecting the Q-III and Q-IV results you should be fine.

Does that make sense?

But then again it looks like you have a decent handle on Trig already....
Title: handle on it?
Post by: Water Bear on January 12, 2004, 11:42:18 PM
Thanx for the help...
but my "handle on trig" is like having a lion by the tail!
can u tell me how to take a snapshot of my screen so that I can post an image?
Title: upside down...
Post by: CAB on January 12, 2004, 11:48:44 PM
Press the Print Screen Key
Open Photo House or other prg
Paste to a new file.

CAB
Title: upside down...
Post by: Water Bear on January 13, 2004, 12:06:23 AM
Quote from: KEB

Of course this will only return the angles where:

0 < ArcCosine < pi

So.....


That is why I thought it should read something like this:
Code: [Select]
(defun ArcCos (num)
    (if
          (AND (NOT (zerop num))
                  (< NUM (* pi 0.5))
          )
    (atan (sqrt (- 1.0 (* num num))) num)
     (errmsg)
    )
  )
Title: upside down...
Post by: Columbia on January 13, 2004, 12:56:27 PM
You could write
Code: [Select]

(if
  (and
    (not (zerop num))
    (< num (* pi 0.5))
  )...

Like this...
Code: [Select]

(if (< 0 num (* pi 0.5))...

Because AutoLISP and VLISP evalutes the expression like this...
0 is less than num which is less than (* pi 0.5)

I know this doesn't really answer your question, but it is an alternate method of computing the evaluation.
Title: upside down...
Post by: SMadsen on January 13, 2004, 02:12:08 PM
Doesn't cosine lie in the range 1.0 to -1.0 (0.0 to pi)?

Code: [Select]
(defun ArcCos (num)
  (cond ((<= -1.0 num 1.0)
         (atan (sqrt (- 1.0 (* num num))) num)
        )
  )
)


(ArcCos -1.0)
3.14159

(ArcCos 1.0)
0.0

(ArcCos 1.5)
nil
Title: Thanks for the memories....
Post by: Water Bear on January 13, 2004, 03:03:08 PM
Hats off to you guys...thanx for the refresher course