Angle between three points
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Angle between three points

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
srinivasan
Guest





Posted: Sat Dec 11, 2004 3:30 pm    Post subject: Angle between three points Reply with 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
John Goodfellow
Guest





Posted: Sat Dec 11, 2004 9:05 pm    Post subject: Re: Angle between three points Reply with quote

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 Reply with 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
devitg
Guest





Posted: Mon Dec 13, 2004 6:09 am    Post subject: Re: Angle between three points Reply with quote

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 Reply with quote

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 Reply with quote

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 Reply with quote

Thanks all.
Back to top
Jorge Jimenez
Guest





Posted: Mon Dec 13, 2004 11:23 am    Post subject: Re: Angle between three points Reply with 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...
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 Reply with quote

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
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB