The Buzzard Posted January 8, 2010 Author Share Posted January 8, 2010 Hi, AFAIK, there's no need to test if the cosine equals 0 to avoid an error. The cos LISP function is implemented so that (cos (/ pi 2)) returns 6.12323e-017 and (cos (* pi 1.5)) -1.83697e-016 rather than 0. So I currently use: (defun tan (a) (/ (sin a) (cos a))) Thanks gile, I tested it and it also works great. Quote Link to comment Share on other sites More sharing options...
gile Posted January 8, 2010 Share Posted January 8, 2010 Thanks gile for the info, any reason why the discrepancy against 0 or just the acad rounding again? I can't say. On one hand, it looks like the unavoidable rounding numbers while a program (not only AutoCAD) is dealing with pi (or other real numbers): (sin 0) returns 0 but (sin pi) returns 1.22465e-016 instead of 0. On the other hand some functions seems to be able to return right results in spite of this necessary rounding of pi value: (= (cos (* 2 pi)) 1) returns T as well as (= -1 (cos pi)) or (= (atan 1 0) (/ pi 2)) or (= (atan -1 0) (/ pi -2)) Quote Link to comment Share on other sites More sharing options...
wizman Posted January 9, 2010 Share Posted January 9, 2010 Thank you gile..'-) Quote Link to comment Share on other sites More sharing options...
pratikchirania Posted May 7, 2010 Share Posted May 7, 2010 Hi, I am new to LISP and am not able to make out much of the code that finds the centre from the start point, end point, bulge and radius. I need to code this in C++. Can anyone help me by giving the logic of the functions(in lisp) used in the previous replys for the same? thanks in advance, Pratik Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 7, 2010 Share Posted May 7, 2010 Perhaps see this post Quote Link to comment Share on other sites More sharing options...
pratikchirania Posted May 7, 2010 Share Posted May 7, 2010 Hi Lee Mac, Thanks for the reply. I did already have a look at the thread you just posted. I was able to make out the derivation of radius, but the following code was not clear to me: centre (polar p1 (+ (- (/ pi 2.) theta/2) (angle p1 p2)) radius)) I dont understand by the Lisp function "polar". Would be grateful if you helped me give the logic of the above lisp code Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 7, 2010 Share Posted May 7, 2010 The polar function is identical to the mathematical sense, in that the arguments take the form of a base point, angle (ACW from X-Axis) and radius. Quote Link to comment Share on other sites More sharing options...
VVA Posted May 9, 2010 Share Posted May 9, 2010 Geometry of the bulge By Stig Madsen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.