TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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..
(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
-
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....
-
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?
-
Press the Print Screen Key
Open Photo House or other prg
Paste to a new file.
CAB
-
Of course this will only return the angles where:
0 < ArcCosine < pi
So.....
That is why I thought it should read something like this:
(defun ArcCos (num)
(if
(AND (NOT (zerop num))
(< NUM (* pi 0.5))
)
(atan (sqrt (- 1.0 (* num num))) num)
(errmsg)
)
)
-
You could write
(if
(and
(not (zerop num))
(< num (* pi 0.5))
)...
Like this...
(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.
-
Doesn't cosine lie in the range 1.0 to -1.0 (0.0 to pi)?
(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
-
Hats off to you guys...thanx for the refresher course