| Author |
Message |
srinivasan
Guest
|
Posted:
Sat Dec 11, 2004 3:30 pm Post subject:
Angle between three points |
|
|
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
|
|
| Back to top |
|
 |
John Goodfellow
Guest
|
Posted:
Sat Dec 11, 2004 9:05 pm Post subject:
Re: Angle between three points |
|
|
Maybe two calls to the Utility object's AngleFromXAxis method and some
arithmetic.
--
John Goodfellow
irtfnm
use john at goodfellowassoc dot com
"srinivasan" <nospam@address.withheld> wrote in message
news:9892675.1102761075951.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri |
|
|
| Back to top |
|
 |
krispy
Guest
|
Posted:
Mon Dec 13, 2004 3:32 am Post subject:
Re: Angle between three points |
|
|
here is a lisp that will return the angle enclosed between three points, where ip is the intersecting point and pt1 and pt2 are the other points:
Here is the code:
| Code: |
(defun enclAngle(pt1 pt2 ip / dist1 dist2 dist3)
(setq dist1 (distance pt1 ip)
dist2 (distance pt2 ip)
dist3 (distance pt1 pt2)
);setq
;; angle = acos((a^2 + b^2 - c^2) / (2*a*b))
(acos (/ (- (+ (sqr dist1) (sqr dist2)) (sqr dist3)) (* 2 dist1 dist2)))
);enclAngle
;;; acos returns the inverse of a cosine
;;; acos(X) = atan(-X / sqrt(-X*X+1)) + 2*atan(1)
(defun acos(value)
(+
(atan (/ (- 0 value) (sqrt (+ (* (- 0 value) value) 1))))
(* 2 (atan 1))
);+
);acos
;;;not sure if sqr is built in
(defun sqr(num)
(* num num)
);sqr
|
|
|
| Back to top |
|
 |
devitg
Guest
|
Posted:
Mon Dec 13, 2004 6:09 am Post subject:
Re: Angle between three points |
|
|
There is a easy way , the old reliable CAL command
(if (= cal nil)
(arxload "geomcal")
)
;; just to chek if GEOMCAL is loaded
(Setq encAngle (c:cal "ang(apex,p1,p2)"));_ the angle included in p1 p2 with
intersection point as apex
Just a KISS: keep it simple .....Sir
Gabriel
"krispy" <nospam@address.withheld> escribió en el mensaje
news:5965053.1102890756341.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | here is a lisp that will return the angle enclosed between three points,
where ip is the intersecting point and pt1 and pt2 are the other points:
Here is the code:
| Code: |
(defun enclAngle(pt1 pt2 ip / dist1 dist2 dist3)
(setq dist1 (distance pt1 ip)
dist2 (distance pt2 ip)
dist3 (distance pt1 pt2)
);setq
;; angle = acos((a^2 + b^2 - c^2) / (2*a*b))
(acos (/ (- (+ (sqr dist1) (sqr dist2)) (sqr dist3)) (* 2 dist1 dist2)))
);enclAngle
;;; acos returns the inverse of a cosine
;;; acos(X) = atan(-X / sqrt(-X*X+1)) + 2*atan(1)
(defun acos(value)
(+
(atan (/ (- 0 value) (sqrt (+ (* (- 0 value) value) 1))))
(* 2 (atan 1))
);+
);acos
;;;not sure if sqr is built in
(defun sqr(num)
(* num num)
);sqr
|
|
|
|
| Back to top |
|
 |
krispy
Guest
|
Posted:
Mon Dec 13, 2004 8:36 am Post subject:
Re: Angle between three points |
|
|
now where's the fun in that?
:) |
|
| Back to top |
|
 |
krispy
Guest
|
Posted:
Mon Dec 13, 2004 9:27 am Post subject:
Re: Angle between three points |
|
|
i think it only fair to point out that instead of:
(c:cal "expression")
you can use
(cal "expression")
hence saving you an additional two key strokes
lol |
|
| Back to top |
|
 |
srinivasan
Guest
|
Posted:
Mon Dec 13, 2004 10:54 am Post subject:
Re: Angle between three points |
|
|
| Thanks all. |
|
| Back to top |
|
 |
Jorge Jimenez
Guest
|
Posted:
Mon Dec 13, 2004 11:23 am Post subject:
Re: Angle between three points |
|
|
This should do it (I leave the testing to you):
The function TPA should return the angle in radians between the three points
(cp is the common point).
Private Function TPA(p1 As Variant, p2 As Variant, cp As Variant) As Double
TPA = Gang(gDX(p1, cp), gDY(p1, cp)) + Gang(gDX(p2, cp), gDY(p2, cp))
End Function
Private Function gDX(pa As Variant, pb As Variant) As Double
gDX = Abs(pb(0) - pa(0))
End Function
Private Function gDY(pa As Variant, pb As Variant) As Double
gDY = Abs(pb(1) - pa(1))
End Function
Private Function Gang(DX As Double, DY As Double) As Double
If DY = 0 Then Gang = 0 Else Gang = Atn(DY / DX)
End Function
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
"srinivasan" <nospam@address.withheld> wrote in message
news:9892675.1102761075951.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri |
|
|
| Back to top |
|
 |
Jorge Jimenez
Guest
|
Posted:
Mon Dec 13, 2004 11:25 am Post subject:
Re: Angle between three points |
|
|
Sorry, last function should be:
Private Function Gang(DX As Double, DY As Double) As Double
If DX = 0 Then Gang = 0 Else Gang = Atn(DY / DX)
End Function
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
"Jorge Jimenez" <unknown@nospam.com> wrote in message
news:41bd354d_2@newsprd01...
| Quote: | This should do it (I leave the testing to you):
The function TPA should return the angle in radians between the three
points
(cp is the common point).
Private Function TPA(p1 As Variant, p2 As Variant, cp As Variant) As
Double
TPA = Gang(gDX(p1, cp), gDY(p1, cp)) + Gang(gDX(p2, cp), gDY(p2, cp))
End Function
Private Function gDX(pa As Variant, pb As Variant) As Double
gDX = Abs(pb(0) - pa(0))
End Function
Private Function gDY(pa As Variant, pb As Variant) As Double
gDY = Abs(pb(1) - pa(1))
End Function
Private Function Gang(DX As Double, DY As Double) As Double
If DY = 0 Then Gang = 0 Else Gang = Atn(DY / DX)
End Function
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
"srinivasan" <nospam@address.withheld> wrote in message
news:9892675.1102761075951.JavaMail.jive@jiveforum2.autodesk.com...
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
|
|
|
| Back to top |
|
 |
|
|
|
|