+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Full Member
    Using
    AutoCAD 2009
    Join Date
    May 2011
    Posts
    70

    Default get the tangential point

    Registered forum members do not see this ad.

    my coding
    Code:
    (setq p1 '(500 200 0)
    (command "circle" ' (0 0 0)  10)
    now at this point i have to draw line from p1 to tangential point on circle.
    how can thisbe done?
    help me.

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    This ?

    Code:
    (vl-load-com)
    (setq p1 '(500 200 0))
    (command "circle" ' (0. 0. 0.) 10.)
    (setq obj (entlast))
    (setq obj (vlax-ename->vla-object obj))
    (setq p2 (vlax-curve-getClosestPointTo obj p1))
    (entmakex (list (cons 0 "LINE")(cons 10 p1)(cons 11 p2)))

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    Tharwat,

    The closest point will be perpendicular, not tangential.
    Lee Mac Programming

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

    Just another Swamper

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    This will return the two points (in WCS) which are tangent to the supplied circle entity from the supplied point projected onto the plane in which the Circle resides; or nil if the supplied point lies inside the circle.

    Code:
    (defun LM:GetTangentPoints ( pt ci / a1 c1 d1 el r1 tn )
    
      (setq el (entget ci)
            c1 (cdr (assoc 10 el))
            r1 (cdr (assoc 40 el))
            d1 (distance pt c1) a1 (angle c1 pt)
      )
      (if (< r1 d1)
        (progn
          (setq tn (sqrt (- (* d1 d1) (* r1 r1)))
                tn (atan tn r1)
          )
          (list
            (trans (polar c1 (+ a1 tn) r1) ci 0)
            (trans (polar c1 (- a1 tn) r1) ci 0)
          )
        )
      )
    )
    A test function:

    Code:
    (defun c:test ( / e p )
    
      (if
        (and
          (setq e (car (entsel "\nSelect Circle: ")))
          (eq "CIRCLE" (cdr (assoc 0 (entget e))))
          (setq p (getpoint "\nSpecify Point: "))
          (setq p (trans p 1 0))
        )
        (foreach x (LM:GetTangentPoints (trans p 0 e) e)
          (entmakex
            (list (cons 0 "LINE") (cons 10 p) (cons 11 x))
          )
        )
      )
    
      (princ)
    )
    Alternatively, here is a function accepting a Point, Circle Center and Circle Radius:

    Code:
    (defun LM:GetTangentPoints ( pt cen rad / a1 d1 tn )
    
      (if (< rad (setq a1 (angle cen pt) d1 (distance pt cen)))
        (progn
          (setq tn (atan (sqrt (- (* d1 d1) (* rad rad))) rad))
          (list
            (trans (polar cen (+ a1 tn) rad) 1 0)
            (trans (polar cen (- a1 tn) rad) 1 0)
          )
        )
      )
    )
    Lee Mac Programming

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

    Just another Swamper

  5. #5
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    As a starting point:

    This should give you length of the tangent line ( s2 ) and the length of the 3 sides forming a right triangle.

    Code:
    (setq p1 '(6 2 0)   ;;;PICK POINT
          ce '(0 0 0)   ;;;CIRCLE CENTER
          ra 2)         ;;;CIRCLE RADIUS
    
    (setq s3 (distance ce p1)
          s1 ra
          s2 (sqrt (- (* s3 s3) (* s1 s1))))

    -David
    R12 (Dos) - A2K

  6. #6
    Senior Member
    Using
    not specified
    Join Date
    Dec 2004
    Location
    YUL
    Posts
    484

    Default

    Registered forum members do not see this ad.

    This is what I would write:

    Code:
    (setq	osn (getvar "osmode")
    	p1 '(0.0 0.0 0.0)
    	r  10.0
    	dx 500.0
    	dy 200.0
    	a  (sqrt (+ (* dx dx) (* dy dy)))
    	b  (sqrt (- (* a a) (* r r)))
    	u1 (atan (/ dy dx))
    	u2 (atan (/ b r))
    	up (+ u1 u2)
    	down (- u1 u2)
    	p2 (polar p1 up r)
    	p3 (polar p1 down r)
    	p4 (polar p1 u1 a)
      )
      (setvar "osmode" 0)
      (command "circle" p1 r)
      (command "line" p2 p4 p3"")
      (setvar "osmode" osn)

Similar Threads

  1. Draw a circle tangential to 3 given circles
    By Alan Cullen in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 1st Jul 2011, 06:29 am
  2. Array 7 perfectly tangential circles
    By Kalai_13 in forum AutoCAD General
    Replies: 5
    Last Post: 24th May 2010, 12:59 am
  3. extruding tangential issues
    By johnnybean in forum AutoCAD 3D Modelling & Rendering
    Replies: 8
    Last Post: 16th Jul 2009, 11:46 pm
  4. Display hidden tangential edges
    By dniemeye in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 7th Jul 2007, 07:47 am
  5. Flatshot command does not show tangential edges
    By Autodesk in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 19th Oct 2006, 12:00 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts