Jump to content

Recommended Posts

Posted

(setq HEIGHT2 (/ HEIGHT 2)

WIDTH2 (/ WIDTH 2)

HYP (sqrt (+ (* HEIGHT2 HEIGHT2)(* WIDTH2 WIDTH2)))

UANG (+ ANG (/ PI 2))

DANG (+ ANG (* PI 1.5))

LANG (+ ANG PI)

HYPANG (+ ANG (cos (/ HEIGHT2 HYP)))

 

)

(setq PP (getpoint "\nGive Your Origin Point: ")

p1 (polar pp HYPANG HYP)

p2 (polar p1 LANG WIDTH)

p3 (polar p2 DANG HEIGHT)

p4 (polar p3 ANG WIDTH)

)

 

This is two parts of a routine to draw 4 side polygon with origin to be center. The hyp cal is correct but the hypang is not coming out correct. I try a 4 x 4 sq knowing it should be 45deg and it comes out 43.5deg.

 

Any help on what I done wrong?

 

Thanks

Posted

Not sure how the variable ANG is retrieved - but its more than likely a degree/radian mix up. :)

Posted

ANG is degree entered at command prompt 0 , 30 , 45 etc

Posted

Assuming that HYPANG is supposed to be the angle of the hypotenuse, couldn't you use

in radians

(setq hypang (atan (/ height2 width2)))

if you need degrees

(defun rtd (a) (/ (* a 180.0) pi))
(setq hypang (rtd (atan (/ height2 width2))))

Posted

(defun c:stock1 (/ HEIGHT WIDTH LENGTH ANG HEIGHT2 WIDTH2

HYP UANG DANG LANG HYPANG CHOICE PP

PT PE P1 P2 P3 P4 )

(setvar "CMDECHO" 0)

(setq

HEIGHT (getreal "\nEnter Stock Height: ")

WIDTH (getreal "\nEnter Stock Width: ")

LENGTH (getreal "\nEnter overall exact Length: ")

ANG (getangle "\nEnter Rotation Angle: ")

 

) ; the end of user input

(if (= ANG nil)

(setq ANG 0)

)

(setq HEIGHT2 (/ HEIGHT 2)

WIDTH2 (/ WIDTH 2)

HYP (sqrt (+ (* HEIGHT2 HEIGHT2)(* WIDTH2 WIDTH2)))

UANG (+ ANG (/ PI 2))

DANG (+ ANG (* PI 1.5))

LANG (+ ANG PI)

HYPANG (+ ANG (cos (/ HEIGHT2 VECTOR)))

 

)

(prompt "\nOK, What do you want? Plan View, Top or Elevation")

(MENU)

)

(defun MENU ()

(initget "Plan Top Elevation Quit")

(setq CHOICE (getpoint "\nPlan/Top/Elevation/Quit: "))

(cond

((= CHOICE "Plan")

(PLAN)

)

((= CHOICE "Top")

(TOP)

)

((= CHOICE "Elevation")

(ELE)

)

((= CHOICE "Quit")

(OK)

)

((null CHOICE)

(prompt"\nYou must enter P,T,E, or Q!")

(MENU)

)

)

)

 

(defun PLAN ()

; PLAN VIEW

(setq PP (getpoint "\nGive Your Origin Point: ")

p1 (polar pp HYPANG HYP)

p2 (polar p1 LANG WIDTH)

p3 (polar p2 DANG HEIGHT)

p4 (polar p3 LANG WIDTH)

)

 

(command "line" p2 p3 p4 p5 "cl")

(redraw)

(MENU)

)

 

(defun TOP ()

;TOP

(setq PT (getpoint "\nGive Your Origin Point: ")

P1 (polar PT LANG WIDTH2)

P2 (polar P1 UANG LENGTH)

P3 (polar P2 ANG WIDTH)

P4 (polar P3 DANG LENGTH)

)

(command "line" p1 p2 p3 p4 "cl")

(MENU)

)

 

(defun ELE ()

;ELEVATION

(setq PE (getpoint "\nGive Your Origin Point: ")

P1 (polar PE UANG HEIGHT2)

P2 (polar P1 ANG LENGTH)

P3 (polar P2 DANG HEIGHT)

P4 (polar P3 LANG LENGTH)

)

 

(command "line" P1 P2 P3 P4 "CL")

(redraw)

(MENU)

)

 

 

(defun OK ()

(getout)

)

Posted

What is the variable "vector"?

 

Also, you have used "length" as one of your variables - I would advise against this as "length" is an AutoLISP function in its own right.

Posted

Sorry about that Vector is now HYP. I have been making changes and try different things I must have missed when I posted.

Posted

There is also no function (getout).

 

But as for the angle, the "getangle" returns in radians and the polar input is in radians also - so I cannot see a problem.

Posted

Thanks a bunch all. the ((setq hypang (atan (/ height2 width2))) worked. As you can tell Im am not great at writing lisp but I think Im getting better. Thanks again

Posted

Glad you got it sorted Bradb, dont worry, you'll get the hang of LISP soon enough :)

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