Jump to content

Calculate the bulge of an arc.


The Buzzard

Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    10

  • wizman

    9

  • Lee Mac

    3

  • gile

    2

Top Posters In This Topic

Posted Images

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))

Link to comment
Share on other sites

  • 3 months later...

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...