Hello,
I got a confusion about infinity number in here.
I'd like to calculate this equation.
(acos (/ b a))
If the constant 'a' is zero, lisp gives me an error. So, I tried to make the
(/ b a) as 'most-positive-short-float' because all expected results are
float.
(acos most-positive-short-float)
This gives me below error.
15 > (acos most-positive-single-float)
> Error: FLOATING-POINT-OVERFLOW detected
> performing * on (1.7976931348623157E+308 1.7976931348623157E+308)
> While executing: CCL::*-2
> Type Command-. to abort.
See the Restarts� menu item for further choices.
How can I get some results without an error?
Thanks, =)
Sungwoo
Sent via Deja.com
http://www.deja.com/
One more thing is...
(acos (/ b a))
If 'a' is zero, what about (/ b a)?
I am confusing..
Does (/ b a) should be an infinity number or just zero?
Thanks,,,,
Sungwoo
Sent via Deja.com
http://www.deja.com/
In article <············@nnrp1.deja.com>, <·······@cad.strath.ac.uk> wrote:
>One more thing is...
>
>(acos (/ b a))
>
>If 'a' is zero, what about (/ b a)?
>I am confusing..
>Does (/ b a) should be an infinity number or just zero?
From the CLHS: "The consequences are unspecified if any argument other than
the first is zero. ... Might signal division-by-zero if division by zero is
attempted."
If your system uses IEEE floating point, there may be an
implementation-specific way to tell it not to signal an error, but instead
to return infinity.
--
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
I changed code for the case of a division with zero.
(acos (if (zerop a)
(/ b least-positive-long-float)
(/ b a)))
I am not sure that this is right way or not.
At least, I can avoid an error, but still confusing...
Anyone can give me some more advice please?
Thanks for advance. =)
Sungwoo
Sent via Deja.com
http://www.deja.com/
·······@cad.strath.ac.uk writes:
> I'd like to calculate this equation.
> (acos (/ b a))
Are you sure? (ACOS X) is real only if X is between -1 and +1.
Perhaps you should be using (ATAN B A) instead.
> Are you sure? (ACOS X) is real only if X is between -1 and +1.
> Perhaps you should be using (ATAN B A) instead.
Let me explain what I am trying to do. I want to get a degree(T) between line
segment a and b. I know the length of line segment a, b, and c which are
respective length of a triangle. In this case, the equation to get a degree
could be written as
(a*a) + (b*b) - 2ab*cos(T) = c*c
This equation can be transferred as
cos(T) = ((a*a)+(b*b)-(c*c)) / 2ab
Consequently, the T is
T = acos(((a*a)+(b*b)-(c*c)) / 2ab)
However, in lisp, the value T is a radian rather than a degree, so I have to
convert it.
Anyway, what I want to do is that get a degree. If '2ab' is zero, then what
should I expect the value of T(radian or degree) instead of an error
(division by zero)? Thanks for advance, =)
Sungwoo
---------
Happy white Christmas
Sent via Deja.com
http://www.deja.com/
In article <············@nnrp1.deja.com>, <·······@cad.strath.ac.uk> wrote:
>Let me explain what I am trying to do. I want to get a degree(T) between line
>segment a and b. I know the length of line segment a, b, and c which are
>respective length of a triangle.
...
>Anyway, what I want to do is that get a degree. If '2ab' is zero, then what
>should I expect the value of T(radian or degree) instead of an error
>(division by zero)? Thanks for advance, =)
2ab can only be zero if a or b is zero. If that's true, the question of
"degree(T) between line segment a and b" makes no sense. This is why
dividing by zero is an error -- when it's the result of analytic geometry,
it usually means you're trying to do something nonsensical like this.
--
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> 2ab can only be zero if a or b is zero. If that's true, the question of
> "degree(T) between line segment a and b" makes no sense. This is why
> dividing by zero is an error -- when it's the result of analytic geometry,
> it usually means you're trying to do something nonsensical like this.
Well, obviously I am not trying to do this nonsensical thing.
I just don't want get an error message when this happen during sketching. =)
Thanks anyway, I got the a clear idea now. =)
Sungwoo
-----------
Merry Christmas.
Sent via Deja.com
http://www.deja.com/
In article <············@nnrp1.deja.com>, <·······@cad.strath.ac.uk> wrote:
>
>> 2ab can only be zero if a or b is zero. If that's true, the question of
>> "degree(T) between line segment a and b" makes no sense. This is why
>> dividing by zero is an error -- when it's the result of analytic geometry,
>> it usually means you're trying to do something nonsensical like this.
>
>Well, obviously I am not trying to do this nonsensical thing.
>I just don't want get an error message when this happen during sketching. =)
>Thanks anyway, I got the a clear idea now. =)
The best solution is to check whether a or b is zero before trying to
compute the angle.
--
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> The best solution is to check whether a or b is zero before trying to
> compute the angle.
Yeap, that is the exactly what I am trying to do. =)
Many thanks,
Sungwoo
Sent via Deja.com
http://www.deja.com/