Author Topic: Radians  (Read 3586 times)

0 Members and 1 Guest are viewing this topic.

JB

  • Guest
Radians
« on: February 19, 2004, 12:03:45 PM »
Do any of you have a set of formulas, to do Right Tringles, in Radian format, That you would be willing to share.
I really just get lost in the shuffle between radians to degees to radians and back !
Thanks !
Jamie:-)
[/img]

CADaver

  • Guest
Radians
« Reply #1 on: February 19, 2004, 12:07:21 PM »
Code: [Select]

(defun dtr (a) (* pi (/ a 180.0)))
(defun rtd (a) (* 180.0 (/ a pi)))


add these to your acad.lsp and they're always there.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Radians
« Reply #2 on: February 19, 2004, 01:17:47 PM »
Code: [Select]

;----------------------------------------------------
; Tangent
(defun tan (x)
  (/ (sin x) (cos x))
  )
;----------------------------------------------------
; Inverse sine
(defun isine (x)
  (atan (/ x (sqrt (- 1.0 (* x x)))))
  )
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Radians
« Reply #3 on: February 19, 2004, 01:20:04 PM »
Thanks to Russ Ludwick for these.
- Russ are we ever going to finish this project?
Code: [Select]

;----------------------------------------------------
; delta angle (degrees) given the chord and radius (real)
; 2 * inverse sine of [ chord ÷ (2 * radius) ] <-,
; not sure of the correct way to write the this  |
(defun get-delta (chord radius / DeltaAng)
  (if
    (or (= (type chord) 'REAL)(= (type radius) 'REAL))
    (setq
      DeltaAng
      (* 2 (rtd (isine (/ chord (* 2 radius)))))
      )
    ); if
  ); defun

;------------------------------------------
; returns the arc length given the radius and delta(deg)
(defun get-arclength (delta radius / arcl)
  (if
    (or (= (type delta) 'REAL)(= (type radius) 'REAL))
    (setq
      arcl
      (* (/ delta 360)(* 2 pi radius))
      )
    ); if
  ); defun

;------------------------------------------
; returns the tangent distance, given the delta(deg) and radius
; tangent = radius * (tangent of 1/2 delta)
(defun get-tangent (delta radius / tangent)
  (if
    (or (= (type delta) 'REAL)(= (type radius) 'REAL))
    (setq
      tangent
      (* radius (tan (dtr (/ delta 2))))
      )
    ); if
  ); defun

;------------------------------------------
; returns the chord distance given the delta(deg) and radius
; chord = 2 * radius * (sine 1/2 delta)
(defun get-chord (delta radius /)
  (if
    (or (= (type delta) 'REAL)(= (type radius) 'REAL))
    (setq
      chord
      (* 2 radius (sin (dtr (/ delta 2))))
      )
    ); if
  ); defun


;------------------------------------------
; returns the mid ordinate, given the delta(deg) and radius
; midordinate = radius - (radius * cosine 1/2 delta)
(defun get-midordinate (delta radius / midord)
  (if
    (or (= (type delta) 'REAL)(= (type radius) 'REAL))
    (setq
      midord
      (- radius (* radius (cos (dtr (/ delta 2)))))
      )
    ); if
  ); defun


;------------------------------------------
; returns the radius given the chord and delta(deg)
; radius = chord ÷ (2 * sine 1/2 delta)
(defun get-radius (chord delta / radius)
  (if
    (or (= (type chord) 'REAL)(= (type delta) 'REAL))
    (setq
      radius
      (/ chord (* 2 (sin (dtr (/ delta 2)))))
      )
    ); if
  ); defun
     

;-----------------------------------------
; returns 1/2 delta given the tangent and radius
; 1/2 delta = inverse tangent of tangent ÷ radius
(defun get-half-delta (tangent radius /)
  (if
    (or (= (type tangent) 'REAL)(= (type radius) 'REAL))
    (setq
      half-delta
      (rtd (atan (/ tangent radius)))
      )
    ); if
  ); defun
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Radians
« Reply #4 on: February 19, 2004, 01:27:27 PM »
Thanks Mark :)

Good Stuff.. I'm squirrelling it away 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JB

  • Guest
Radians
« Reply #5 on: February 19, 2004, 03:30:55 PM »
I want to Than You all !
This is a wonderful Site. I have used and learned many new tricks in lisp. I am Trying to learn to use the "Vlisp" editor. Marvelous tool !
I got alot of help from you all so I am going to sharethis code.
It may be primitive and it is not complete, But it will run a metal building frame outline. I am one step closer !!
Thanks Again !
Jamie:-)
Code: [Select]

;convert angles into degrees and degrees to angles
(defun dtr (a) (* pi (/ a 180.0)))
(defun rtd (a) (* 180.0 (/ a pi)))
; Tangent
(defun tan (a) (/ (sin a) (cos a)))

(defun c:frmotln (/ )
;acquire user input
(textscr)
(princ "please use setup with dimscale @ 32 and all new layers")
(princ)
  (initget (+ 1 2 4 8))
  (setq owidth (getdist "\nWhat is Building Overall Width?: "))
(initget (+ 1 2 4 8))
        (setq EAVEHEIGHT (getDIST "\nWhat is the Eave Height in Feet - example - 12'-4:  "))
  (initget (+ 1 2 4 8))
(setq ROOFPITCH (getDIST "\nWhat is the roof pitch to 12 -example 3- for 3:12 pitch:  "))
  (initget (+ 1 2 4 8))
(setq HAUNCH (getDIST "\nWhat is haunch depth -example 23 = 23 inches:  "))
    (SETQ SP (LIST 0.0 0.0))
(SETQ EH (LIST 0.0 EAVEHEIGHT))
  (SETQ BP (LIST 8.0 0.0))
  (setq width (abs (- 6.0 (/ OWIDTH 2.0))))
(SETQ RFPTCH (LIST 12.0 ROOFPITCH))
(SETQ PITCH (ANGLE SP RFPTCH))
(SETQ REVPITCH (ANGLE RFPTCH SP))
(setq UP (ANGLE SP EH))
(SETQ RIGHT (ANGLE SP BP))
(SETQ LEFT (ANGLE BP SP))
(SETQ DOWN (ANGLE EH SP))
(SETQ PITCHP90 (+ PITCH (DTR 90))) ; ROOF PITCH ANGLE + 90 DEG
(SETQ PITCHM90 (- PITCH (DTR 90))) ; ROOF PITCH ANGLE - 90 DEG
(setq tm1 (abs (/ (- pitch (DTR 90.0)) 2.0)))
  (print tm1)
  (setq rise (* haunch (tan tm1)))
  (setq hc1 (- eaveheight rise))
  (setq hc (list haunch hc1))
  (setq rise2 (* width (tan pitch)))
  (setq pp (list width (+ rise2 eaveheight)))
  (setq p1 (polar pp down 9.0))
(command "pline" sp eh pp p1 hc bp "c")
  (command "pline" eh hc "")
PRINC)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Radians
« Reply #6 on: February 19, 2004, 03:34:50 PM »
I was the one who edited your post Jamie. It was lacking the beginning [code] tag an thus made it hard to read.
TheSwamp.org  (serving the CAD community since 2003)

JB

  • Guest
Radians
« Reply #7 on: February 19, 2004, 03:59:27 PM »
Thanks I had No Idea I had missed the "code" tag. Still just Learning !
Jamie:-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Radians
« Reply #8 on: February 19, 2004, 05:38:50 PM »
JB, how about adding your CAD info to your profile (you see that on most of the swamp-rat's profiles) that way we all know what version you are trying to make work, and can offer suggestions on how to improve your situation.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie