Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
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@jiveforum 2.autodesk.com...
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
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
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@jiveforum 2.autodesk.com...
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
now where's the fun in that?
:)
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
Thanks all.
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@jiveforum 2.autodesk.com...
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
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...
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@jiveforum 2.autodesk.com...
Hello all
Is there any way to calculate the angle between three
points, ///r to dimangular vertex option.
Thanks in advance.
Sri
3rd to 1st Angle
I am confusing with angle
if/Cond angle