Hi All,
I want to draw a tangent to a circle from a point outside the cirle using vb.net.
I have following data....
Radius of circle
Coordinate of center of circle
coordinate of external point from where tangent has to draw.
Can u help me..........?
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi,
The tangent points from a point to a circle are the intersection points betwenn the circle and another one wich center is the middle of the line between the circle center and the point and which radius is the half of this line length (see picture).
Programatically, create a temporary circle as discribe, get the intersection points, delete the circle...
Appologies for my poor English.
Here's a little 'quick and dirty' C# sample
// Creates two lines from a point tangent to a circle private void TangentsToCircle(ObjectId id, Point3d pt) { Document doc = acadApp.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; Circle c = tr.GetObject(id, OpenMode.ForRead) as Circle; if (c == null) { ed.WriteMessage("\nIncorrect ObjectId"); return; } if (pt.DistanceTo(c.Center) <= c.Radius) { ed.WriteMessage("\nUnavailable tangents"); return; } Vector3d vec = pt.GetVectorTo(c.Center) / 2.0; double rad = vec.Length; CircularArc3d c3d = new CircularArc3d(c.Center, c.Normal, c.Radius); CircularArc3d tmp = new CircularArc3d(pt + vec, c.Normal, rad); Point3d[] inters = c3d.IntersectWith(tmp); foreach (Point3d p in inters) { Line l = new Line(pt, p); btr.AppendEntity(l); tr.AddNewlyCreatedDBObject(l, true); } tr.Commit(); } }
Hi
this is helpful
can u explain the syntax of .IntersectWith
In the Syntax of intersectWith there r more parameter , but u have use only one?
Hi,
The DatabaseServices.Entity.IntersectWith() method requires more than one parameter.
I'm using the Geometry.CircularArc3d.IntersectWith() one.
The CircularArc3d as others Geometry namespace classes define 'abstract' geometrical objects which aren't database entities.
A tangent is always perpendicular to the radius of a circle. And given that for every external point to a curcle, there are two tangent lines, the tangents will not be located on a radius that passes through the center of the circle.
The way to find the tangents is to use the pythagorean theorem.
The hypotenuse of the right triangle is the distance between the external point and the circle's center point.
The short leg of the triangle is the radius of the circle.
The remaining leg (b) is then easily found. It is the square root result of the hypotenuse square minus the radius squared. A circle with this radius "b" having its center located at the external point will pass through the tangent point on the original circle.
my bad....gile is correct when taking the centerpoint of the circle at the midpoint of the line between original centerpoint and external point. I should have read things more closely - sorry.