Aftertouch Posted December 12, 2017 Share Posted December 12, 2017 Hello all, Im having some problems with calculating a bulge factor... I have the following situation: I manage to get a list with all coordinates, and the bulge factor in the right place. Altho... it seems my bulgefactor is calculated wrong... I manage to get all lengths of the magenta lines with the matching coordinates. So my formula is: Where arcbulge is the length of the 'vertical' line to the centerpoint of the desired circle. (setq bulge (/ (tan arcbulge) 4)) But this results in a bulge of 0.0571689, while im looking for a value of: 0.71248. Here are the coords of the points: 106357.129 507429.816 startpoint 106362.918 507433.010 random point on the arc. 106366.580 507429.816 endpoint Where am i going wrong? Quote Link to comment Share on other sites More sharing options...
rlx Posted December 12, 2017 Share Posted December 12, 2017 I have exactly 0 experience with bulge factors but here's a link with peoples who seem to have : http://www.cadtutor.net/forum/showthread.php?43619-Calculate-the-bulge-of-an-arc.&highlight=bulge gr. Rlx Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 12, 2017 Share Posted December 12, 2017 Look into attached PNG... Quote Link to comment Share on other sites More sharing options...
rlx Posted December 12, 2017 Share Posted December 12, 2017 Look into attached PNG... Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted December 12, 2017 Author Share Posted December 12, 2017 Thanks for your Reply Marko. This leads me into another question.... How can i get the angle? Since there are cases, where i just got 3 points. Start, Arcpoint, End. Then i dont have any reference to get the angle? Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 12, 2017 Share Posted December 12, 2017 (edited) Analyze this link : http://www.lee-mac.com/bulgeconversion.html Edited December 12, 2017 by marko_ribar Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted December 14, 2017 Author Share Posted December 14, 2017 I foudn this on the webs after a long search. (DEFUN WIKI-3PTTOBULGE (PNT1 PNT2 PNT3 / ANG1 ANG2 ANG3 BULGE CHORD DELTA DELTA1 R) (COND ((NOT PNT2) 0 ) (T (SETQ CHORD (DISTANCE PNT1 PNT3)) (setq ANG2 (- (ANGLE PNT2 PNT1) (ANGLE PNT2 PNT3))) (setq R (/ CHORD (* 2 (SIN ANG2)))) (setq DELTA1 (* 2 (WIKI-ASIN (/ CHORD (* 2 R))))) (setq ANG1 (ABS (- (ANGLE PNT1 PNT3) (ANGLE PNT1 PNT2)))) (setq ANG1 (ABS (IF (> ANG1 PI)(- ANG1 (* 2 PI)) ANG1))) (setq ANG3 (ABS (- (ANGLE PNT3 PNT1) (ANGLE PNT3 PNT2)))) (setq ANG3 (ABS (IF (> ANG3 PI)(- ANG3 (* 2 PI)) ANG3))) (setq DELTA (* 2 (+ ANG1 ANG3))) (setq BULGE (* (IF (MINUSP R) -1 1)(WIKI-TAN (/ DELTA 4.0)))) ) ) ) (DEFUN WIKI-TAN (X) (/ (SIN X) (COS X)) ) (DEFUN WIKI-ASIN (X) (ATAN X (SQRT (- 1 (* X X)))) ) Seems to do the trick. :-) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 14, 2017 Share Posted December 14, 2017 I think this is sufficient: ;; 3-Points to Bulge - Lee Mac (defun LM:3p->bulge ( p1 p2 p3 ) ((lambda ( a ) (/ (sin a) (cos a))) (/ (+ (- pi (angle p2 p1)) (angle p2 p3)) 2)) ) WCS Example: (defun c:test ( / p1 p2 p3 ) (if (and (setq p1 (getpoint "\nSpecify 1st Point: ")) (setq p2 (getpoint "\nSpecify 2nd Point: " p1)) (setq p3 (getpoint "\nSpecify 3rd Point: " p2)) ) (entmake (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 2) '(070 . 0) (cons 10 p1) (cons 42 (LM:3p->bulge p1 p2 p3)) (cons 10 p3) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted December 15, 2017 Author Share Posted December 15, 2017 Lee Mac, your the best! That takes away alot of coding with the same result. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 15, 2017 Share Posted December 15, 2017 You're welcome! Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 15, 2017 Share Posted December 15, 2017 Not sure if SetBulge and GetBulge methods are holding the same value as the 42 group code, but along with LM:3p->bulge the task becomes even easier: (vla-SetBulge plineObj vtx (LM:3p->bulge p1 p2 p3)) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 16, 2017 Share Posted December 16, 2017 ;; 3-Points to Bulge - M.R. (defun MR:3p->bulge ( p1 p2 p3 / mid asin clockwise m12 m23 c r ) (defun mid ( p1 p2 ) (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2) ) (defun asin ( x ) (cond ((equal x 1.0 1e- (/ pi 2.0)) ((equal x -1.0 1e- (* 3.0 (/ pi 2.0))) ((equal x 0.0 1e- 0.0) ((equal x -0.0 1e- pi) ((atan (/ x (sqrt (- 1.0 (* x x)))))) ) ) (defun clockwise ( p1 p2 p3 ) (minusp (- (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1))) (* (- (car p3) (car p1)) (- (cadr p2) (cadr p1))))) ) (setq m12 (mid p1 p2)) (setq m23 (mid p2 p3)) (setq c (inters m12 (polar m12 (+ (angle p1 p2) (* 0.5 pi)) 1.0) m23 (polar m23 (+ (angle p2 p3) (* 0.5 pi)) 1.0) nil)) (setq r (distance c p1)) (if (not (clockwise p1 p2 p3)) (if (<= (rem (+ pi pi (- (angle c p3) (angle c p1))) (+ pi pi)) pi) ((lambda ( a ) (/ (sin a) (cos a))) (/ (asin (/ (distance p1 p3) r 2.0)) 2.0)) ((lambda ( b ) (/ 1.0 b)) ((lambda ( a ) (/ (sin a) (cos a))) (/ (asin (/ (distance p1 p3) r 2.0)) 2.0))) ) (if (<= (rem (+ pi pi (- (angle c p1) (angle c p3))) (+ pi pi)) pi) ((lambda ( a ) (- (/ (sin a) (cos a)))) (/ (asin (/ (distance p1 p3) r 2.0)) 2.0)) ((lambda ( b ) (- (/ 1.0 b))) ((lambda ( a ) (/ (sin a) (cos a))) (/ (asin (/ (distance p1 p3) r 2.0)) 2.0))) ) ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 16, 2017 Share Posted December 16, 2017 Good idea to check clockwise-p, although I'm not sure if thats important. Marko, I don't understand such math codes, but I think you could shorten a bit: (setq plst (list p1 p2 p3)) (if (clockwise plst) (apply 'fun plst) (apply 'fun (reverse plst)) ) Quote Link to comment Share on other sites More sharing options...
gsc Posted December 21, 2017 Share Posted December 21, 2017 (edited) What would be the bulge formula be if p2 is a cp and the bulge is calculated between p1 and p3 (both p1 and p3 are on cp circle)? I think this is sufficient:;; 3-Points to Bulge - Lee Mac (defun LM:3p->bulge ( p1 p2 p3 ) ((lambda ( a ) (/ (sin a) (cos a))) (/ (+ (- pi (angle p2 p1)) (angle p2 p3)) 2)) ) WCS Example: (defun c:test ( / p1 p2 p3 ) (if (and (setq p1 (getpoint "\nSpecify 1st Point: ")) (setq p2 (getpoint "\nSpecify 2nd Point: " p1)) (setq p3 (getpoint "\nSpecify 3rd Point: " p2)) ) (entmake (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 2) '(070 . 0) (cons 10 p1) (cons 42 (LM:3p->bulge p1 p2 p3)) (cons 10 p3) ) ) ) (princ) ) Edited December 21, 2017 by gsc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.