### Author Topic: how to calculate point in this triangle  (Read 799 times)

0 Members and 1 Guest are viewing this topic.

#### TopoWAR

• Newt
• Posts: 59
##### how to calculate point in this triangle
« on: April 21, 2012, 08:34:23 pm »
I use a theodolite mounted EDM, what I want is to calculate the distance given by the EDM using the zenith angle of the theodolite, I hope I understand, thanks
Thanks for help

#### ribarm

• Bull Frog
• Posts: 438
• Marko Ribar, architect
##### Re: how to calculate point in this triangle
« Reply #1 on: April 22, 2012, 05:59:02 am »
Check *.dwg... I've calculated distance...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### TopoWAR

• Newt
• Posts: 59
##### Re: how to calculate point in this triangle
« Reply #2 on: April 22, 2012, 09:24:20 am »
ribarm , Thanks for your time, but I do not understand trigonometry, maybe someone translates it to lisp
Thanks for help

#### paulmcz

• Newt
• Posts: 179
##### Re: how to calculate point in this triangle
« Reply #3 on: April 22, 2012, 08:15:28 pm »
If  "x" value of point pt2 = 0 and "y" value of point pt2 = 0, here is a lisp that will get you coordinates of the point you want (pt3).

Code: [Select]
`(defun asin (xxxx)      (atan (/ xxxx (sqrt (- 1.0 (expt xxxx 2))))))(defun c:pt3 (/ xpt2 ypt2 be a b sinal ug y x xpt3 ypt3)  (setq xpt2 0 ypt2 0 be (/ (* 95 pi) 180) a 0.2 b 10.0 sinal (/ (* a (sin be)) b) ug    (- pi be (asin sinal)) y     (* b (cos ug)) x     (* b (sin ug)) xpt3  (+ xpt2 x) ypt3  (- ypt2 y)  )  (alert (strcat "x = " (rtos xpt3 2 4) "\ny = " (rtos ypt3 2 4)))  (princ))`

#### TopoWAR

• Newt
• Posts: 59
##### Re: how to calculate point in this triangle
« Reply #4 on: April 22, 2012, 09:26:05 pm »
paulmcz ,  this example is sufficient for what I need, thanks for helping
Thanks for help

#### TopoWAR

• Newt
• Posts: 59
##### Re: how to calculate point in this triangle
« Reply #5 on: April 22, 2012, 10:35:52 pm »
paulmcz , I did some testing, I miscalculates lisp, you can see the dwg? thanks

the problem seems to be in the minutes and seconds, 101 ° 30'30 "
does me no good calculation, as I fix this?

I guess you have to convert degrees to radians, but how?
« Last Edit: April 22, 2012, 11:23:28 pm by TopoWAR »
Thanks for help

#### paulmcz

• Newt
• Posts: 179
##### Re: how to calculate point in this triangle
« Reply #6 on: April 23, 2012, 12:01:47 am »
The code was not written for all possible configurations.
Here is a new one, made for zenith angle either greater or smaller than 90 deg.

Code: [Select]
`(defun asin (xxxx)  (atan (/ xxxx (sqrt (- 1.0 (expt xxxx 2))))))(defun c:pt3 (/ xpt2 ypt2 be a b sinal y x xpt3 ypt3)  (setq xpt2 0 ypt2 0 be (/ (* 80.2583 pi) 180) a  0.5 b  20.0)(cond ((> pi be (* pi 0.5))   (setq sinal (/ (* a (sin be)) b) ug    (- pi be (asin sinal)) y     (* b (cos ug)) x     (* b (sin ug)) xpt3  (+ xpt2 x) ypt3  (- ypt2 y)   )  (alert (strcat "x = " (rtos xpt3 2 4) "\ny = " (rtos ypt3 2 4))))            ((< 0 be (* pi 0.5))       (setq sinal (/ (* a (sin be)) b)      ug    (- pi (- pi be (asin sinal)))      y    (* b (cos ug))      x    (* b (sin ug))      xpt3  (+ xpt2 x)      ypt3  (+ ypt2 y)       )  (alert (strcat "x = " (rtos xpt3 2 4) "\ny = " (rtos ypt3 2 4))))      (t nil))  (princ))`

#### TopoWAR

• Newt
• Posts: 59
##### Re: how to calculate point in this triangle
« Reply #7 on: April 23, 2012, 12:10:16 am »
paulmcz , Thanks, I'll see how it works
Thanks for help

#### Stefan

• Newt
• Posts: 121
##### Re: how to calculate point in this triangle
« Reply #8 on: April 23, 2012, 02:31:22 am »
Maybe this
Code - Auto/Visual Lisp: [Select]
`(defun ptx (d u h e / x)  (list    (* (sin (setq u (/ (* pi u) 180.)))       (setq x (+ (* e (cos u))                  (sqrt (- (expt d 2.0)                           (expt (* e (sin u)) 2.0)                        )                  )               )       )    )    (+ h (* x (cos u)))  ))`
where:
- d is measured distance (10.00 in your sample)
- u angle decimal degrees (95.00 deg)
- h theodolite height  (1.50)
- e EDM height  (0.20)
The result is a point (x y), measured from theodolite base.

#### ribarm

• Bull Frog
• Posts: 438
• Marko Ribar, architect
##### Re: how to calculate point in this triangle
« Reply #9 on: April 23, 2012, 04:29:33 am »
Here is mine version :

Code - Auto/Visual Lisp: [Select]
`(defun c:slopepoint ( / A ANG ANGR D EDM P PP PT PTT TG X X1 X2 Y)  (setq pt (getpoint "\nPick point from witch to calculate coordinates of new point - point on top of theodolite : "))  (setvar 'orthomode 1)  (setq EDM (getdist pt "\nPick height of EDM [make sure you typed correct SI unit - m, cm, mm,...] : "))  (setvar 'orthomode 0)  (setq ptt (polar pt (/ pi 2.0) EDM))  (setq D (getdist ptt "\nPick slope distance [make sure you typed correct SI unit - m, cm, mm,...] : "))  (while (not (>= 180.0 (setq A (getreal "\nInput angle of zenith in decimal degrees [180 >= A >= 90] : ")) 90.0)))  (setq ang (- A 90.0))  (setq angr (cvunit ang "degrees" "radians"))  (setq tg (/ (sin angr) (cos angr)));; (x*tg+EDM)^2+x^2=D^2;; x^2*tg^2+2*x*tg*EDM+EDM^2+x^2-D^2=0;; x^2*(tg^2+1)+x*2*tg*EDM+EDM^2-D^2=0;; x=(-tg*EDM +- (sqrt (tg^2*EDM^2 - (tg^2+1)*(EDM^2-D^2)))) / (tg^2+1)  (setq x1 (/ (+ (* (- 1) tg EDM) (sqrt (- (* (expt tg 2) (expt EDM 2)) (* (+ (expt tg 2) 1.0) (- (expt EDM 2) (expt D 2)))))) (+ (expt tg 2) 1.0)))  (setq x2 (/ (- (* (- 1) tg EDM) (sqrt (- (* (expt tg 2) (expt EDM 2)) (* (+ (expt tg 2) 1.0) (- (expt EDM 2) (expt D 2)))))) (+ (expt tg 2) 1.0)))  (if (minusp x2) (setq x x1) (setq x x2))  (setq y (* x tg))  (setq pp (list x (- y) 0.0))  (setq p (mapcar '+ pt pp))  (prompt "\nDestination point has these coordinates : ")(print p)  (textpage)  (princ)) `

M.R.
« Last Edit: April 23, 2012, 06:07:48 am by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### Lee Mac

• Needs a day job
• Posts: 8817
• AutoCAD 2013 Windows 7 London, England
##### Re: how to calculate point in this triangle
« Reply #10 on: April 23, 2012, 06:18:32 am »
Nice derivation Stefan

Here is another approach, not quite as elegant:

Code - Auto/Visual Lisp: [Select]
`(defun ptx ( d u h e / a b )    (setq a (/ (* e (sin (setq u (* pi (/ u 180.0))))) d)          b (- pi u (atan a (sqrt (- 1.0 (* a a)))))    )    (list (* d (sin b)) (- (+ e h) (* d (cos b)))))`
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?

#### paulmcz

• Newt
• Posts: 179
##### Re: how to calculate point in this triangle
« Reply #11 on: April 23, 2012, 09:12:07 am »
I guess you have to convert degrees to radians, but how?

Code: [Select]
`(defun dmsr (deg mi sec); degrees, minutes, seconds  (/ (* pi (+ deg (/ mi 60.0)(/ sec 3600.0))) 180.0))`

#### Lee Mac

• Needs a day job
• Posts: 8817
• AutoCAD 2013 Windows 7 London, England
##### Re: how to calculate point in this triangle
« Reply #12 on: April 23, 2012, 09:24:29 am »
Or

Code - Auto/Visual Lisp: [Select]
`angtof`

Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?

#### TopoWAR

• Newt
• Posts: 59
##### Re: how to calculate point in this triangle
« Reply #13 on: April 23, 2012, 09:38:29 am »
indeed, I learn every day thanks to you, thanks
Thanks for help

#### ElpanovEvgeniy

• Swamp Rat
• Posts: 1398
• Moscow (Russia)
##### Re: how to calculate point in this triangle
« Reply #14 on: April 23, 2012, 09:42:53 am »
An example without using sin / cos

Code - Auto/Visual Lisp: [Select]
`(defun ptx (p1 p2 a r)  (polar (setq P1 (inters P1 (polar P1 a 10.0) P2 (polar P2 (+ A (/ pi 2.)) 10.0) nil))         A         (sqrt (- (expt R 2) (expt (distance P2 P1) 2)))  ))`
test:
Code - Auto/Visual Lisp: [Select]
`(setq p1 (getpoint "\n P1")      a  (getorient p1 "\n angle")      p2 (getpoint "\n P2")      r  10.)(ptx p1 p2 a r)`
« Last Edit: April 23, 2012, 09:50:56 am by ElpanovEvgeniy »
В жизни нет хорошего или плохого, а есть лишь бесконечные возможности для обучения.