Author Topic: upside down...  (Read 4676 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
upside down...
« 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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
upside down...
« Reply #1 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....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Water Bear

  • Guest
handle on it?
« Reply #2 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?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
upside down...
« Reply #3 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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
upside down...
« Reply #4 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)
    )
  )

Columbia

  • Guest
upside down...
« Reply #5 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.

SMadsen

  • Guest
upside down...
« Reply #6 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

Water Bear

  • Guest
Thanks for the memories....
« Reply #7 on: January 13, 2004, 03:03:08 PM »
Hats off to you guys...thanx for the refresher course