:oops:
There was a mistake in the Triangle2d.IsPointInside() method.
Attached file in the first post is updated.
I'm pretty sure you working on Rectangle 2d/3d as wellI'm not so sure, IMO, in geometry (almost 3d geometry) rectangles are'nt as useful as triangles which are not deformable, define planes and so on...
Gile, Thank you your great library, I will learn a lot from it~
type Viewport with
member vp.DCS2PSDCS =
Matrix3d.Scaling(vp.CustomScale, vp.CenterPoint) *
Matrix3d.Displacement(vp.CenterPoint - Point3d.Origin) *
Matrix3d.Displacement(Point3d.Origin - vp.ViewCenter.To3d)
member vp.PSDCS2DCS = vp.DCS2PSDCS.Inverse()
member vp.DCS2WCS =
Matrix3d.Rotation(-vp.TwistAngle, vp.ViewDirection, vp.ViewTarget) *
Matrix3d.Displacement(vp.ViewTarget - Point3d.Origin) *
Matrix3d.PlaneToWorld vp.ViewDirection
member vp.WCS2DCS = vp.DCS2WCS.Inverse()
there was a minor snag in appropriating your intellectual propertyI do not really care about "intellectual property" with the code I post on TheSwamp or elsewhere. I learn a lot from you and others and most of the code I write is "hacked" from what I read.
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using GeometryExtensions;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace GeometryExtensionsTestCommands
{
public class MjoinCommand
{
[CommandMethod("mjoin")]
public void PolyJoin()
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
TypedValue[] filter = {
new TypedValue(-4,"<OR"),
new TypedValue(0, "ARC,ELLIPSE,LINE,LWPOLYLINE"),
new TypedValue(-4, "<AND"),
new TypedValue(0, "SPLINE"),
new TypedValue(-4, "&"),
new TypedValue(70, 8),
new TypedValue(-4, "AND>"),
new TypedValue(-4, "OR>")};
PromptSelectionResult psr = ed.GetSelection(new SelectionFilter(filter));
if (psr.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
PolylineSegmentCollection psc = new PolylineSegmentCollection();
Plane plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
foreach (ObjectId id in psr.Value.GetObjectIds())
{
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
switch (ent.GetType().Name)
{
case "Arc":
Arc arc = (Arc)ent;
psc.Add(new PolylineSegment(
new CircularArc2d(
arc.Center.Convert2d(plane),
arc.Radius,
arc.StartAngle,
arc.EndAngle,
Vector2d.XAxis,
false)));
break;
case "Ellipse":
Ellipse el = (Ellipse)ent;
psc.AddRange(new PolylineSegmentCollection(el));
break;
case "Line":
Line l = (Line)ent;
psc.Add(new PolylineSegment(
new LineSegment2d(
l.StartPoint.Convert2d(plane),
l.EndPoint.Convert2d(plane))));
break;
case "Polyline":
Polyline pl = (Polyline)ent;
psc.AddRange(new PolylineSegmentCollection(pl));
break;
case "Spline":
try
{
Spline spl = (Spline)ent;
psc.AddRange(new PolylineSegmentCollection((Polyline)spl.ToPolyline()));
}
catch { }
break;
default:
break;
}
}
foreach (PolylineSegmentCollection segs in psc.Join())
{
Polyline pline = segs.ToPolyline();
btr.AppendEntity(pline);
tr.AddNewlyCreatedDBObject(pline, true);
}
tr.Commit();
}
}
}
}
[CommandMethod("bisect", CommandFlags.Modal | CommandFlags.Redraw)]
public static void TestForBiLine()
{
// Get the current document and database
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
// Select lines
PromptEntityOptions opt = new PromptEntityOptions("\nSelect a first line:");
opt.SetRejectMessage("\nMust be selected the line only!");
opt.AddAllowedClass(typeof(Line),false);
PromptEntityResult res1 = ed.GetEntity(opt);
// Set 'black hole' to exit if something wrong
if (res1.Status != PromptStatus.OK)return;
opt= new PromptEntityOptions("\nSelect a second line:");
PromptEntityResult res2 = ed.GetEntity(opt);
// Set 'black hole' to exit if something wrong
if (res2.Status != PromptStatus.OK) return;
// Open transaction
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
DBObject obj1 = tr.GetObject(res1.ObjectId, OpenMode.ForWrite);
Line ln1 = obj1 as Line;
// Set 'black hole' to exit if something wrong
if (ln1 == null) return;
DBObject obj2 = tr.GetObject(res2.ObjectId, OpenMode.ForWrite);
Line ln2 = obj2 as Line;
// Set 'black hole' to exit if something wrong
if (ln2 == null) return;
Point3d ps1 = ln1.StartPoint;
Point3d pe1 = ln1.EndPoint;
Point3d ps2 = ln2.StartPoint;
Point3d pe2 = ln2.EndPoint;
Point3dCollection pts = new Point3dCollection();
ln1.IntersectWith(ln2, Intersect.ExtendBoth, pts, 0, 0);
// Set 'black hole' to exit if no intersection
if (pts.Count != 1)
{
acadApp.ShowAlertDialog("Lines are colinear or does not intersects each another");
return;
}
// Calculate nearest point to the first line
Point3d pk1 = res1.PickedPoint;
pk1 = ln1.GetClosestPointTo(pk1, true);
// Calculate nearest point to the first line
Point3d pk2 = res2.PickedPoint;
pk2 = ln2.GetClosestPointTo(pk2, true);
// Swap start and end points if lines has different direction
if (ps1.DistanceTo(ps2) + pe1.DistanceTo(pe2) > (ps1.DistanceTo(pe2) + pe1.DistanceTo(ps2)))
{
Point3d tp = new Point3d(ps1.X, ps1.Y, ps1.Z);
ps1 = pe1;
pe1 = tp;
}
// create the first temporary Line3d object
Line3d tl1 = new Line3d(ps1, ps2);
// Calculate midpoint of this line
Point3d tp1 = tl1.EvaluatePoint(0.5);
// create the second temporary Line3d object
Line3d tl2 = new Line3d(pe1, pe2);
// Calculate midpoint of this line
Point3d tp2 = tl2.EvaluatePoint(0.5);
// Create bisector line
Line ln = new Line(tp1, tp2);
ln.SetDatabaseDefaults();
BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
// Append line to the current space and transaction
btr.AppendEntity(ln);
tr.AddNewlyCreatedDBObject(ln, true);
// Commit transaction
tr.Commit();
}
}
[CommandMethod("circ3p")]// This method can have any name
public static void TestFor3PointCircle()
{
// Get the document and database
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
// If we have a valid point selection, get all 3 points
PromptPointOptions ppo = new PromptPointOptions("\nPick a point : ");
ppo.AllowNone = true;
PromptPointResult ppr;
ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
Point3d p1= ppr.Value;
ppo = new PromptPointOptions("\nPick a second point : ");
ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
Point3d p2= ppr.Value;
ppo = new PromptPointOptions("\nPick a third point : ");
ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
Point3d p3= ppr.Value;
// To pass center point by reference
Point3d pc = new Point3d();
// Get result
bool result = CircleCenter(p1, p2, p3, out pc);
if (result)
ed.WriteMessage("\nCenter point calculated:\t{0:f3},{1:f3},{2:f3}", pc.X, pc.Y, pc.Z);
else return;
// Calculate radius
double rad = pc.DistanceTo(p1);
// Open transaction and add circle to the current space
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Circle circ = new Circle(pc, Vector3d.ZAxis, rad);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(circ);
tr.AddNewlyCreatedDBObject(circ, true);
// Commit transaction
tr.Commit();
}
}
public static bool CircleCenter(Point3d p0, Point3d pm, Point3d p1, out Point3d pc)
{
Vector3d v1 = p0 - pm;
Vector3d v2 = p1 - pm;
if (v1.IsParallelTo(v2))
{
pc = new Point3d();
return false;
}
CircularArc3d crc = new CircularArc3d(p0, pm, p1);
pc = crc.Center;
return true;
}
}
[CommandMethod("trt", CommandFlags.UsePickSet)]
public void TrimToPlane()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions
("\nPick a line to extend/trim to the current Ucs:");
peo.SetRejectMessage("Must be a line:");
peo.AddAllowedClass(typeof(Line), true);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
Matrix3d Ucs = ed.CurrentUserCoordinateSystem;
using(Transaction tr = db.TransactionManager.StartTransaction())
{
Line line=tr.GetObject(per.ObjectId,OpenMode.ForWrite) as Line;
Point3d p = line.StartPoint;
Point3d pt = Ucs.CoordinateSystem3d.Origin;
Vector3d v = line.EndPoint - line.StartPoint; //line.Delta;//.GetNormal();
Vector3d n = Ucs.CoordinateSystem3d.Zaxis;
//double Elev = pt.X * n.X + pt.Y * n.Y + pt.Z * n.Z;
//double Dist = (Elev - (p.X * n.X) - (p.Y * n.Y) - (p.Z * n.Z)) / ((v.X * n.X) + (v.Y * n.Y) + (v.Z * n.Z));
//Point3d intersectionPt=new Point3d(p.X + Dist * v.X, p.Y + Dist * v.Y, p.Z + Dist * v.Z);
if (Math.Abs( n.DotProduct(v))<0.00000001)
{
MessageBox.Show("The plane and line-segment are parallel, no intersection:");
return;
}
double t = n.DotProduct((pt-p))/n.DotProduct(v);
Point3d ptofIntersection=p + v.MultiplyBy(t);
if ((p - ptofIntersection).Length > (line.EndPoint - ptofIntersection).Length)
line.EndPoint = ptofIntersection;
else
line.StartPoint = ptofIntersection;
//http://www.thepolygoners.com/tutorials/lineplane/lineplane.html
//If:
//t > 0 and t < 1:The intersection occurs between the two end points
//t = 0:The intersection falls on the first end point
//t = 1:Intersection falls on the second end point
//t > 1:Intersection occurs beyond second end Point
//t < 0:Intersection happens before 1st end point.
tr.Commit();
}
}
/// <summary>
/// Creates a new instance of PolylineSegmentCollection from a Line.
/// </summary>
/// <param name="line">A Line instance.</param>
public PolylineSegmentCollection(Line line)
{
Plane plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
_contents.Add(new PolylineSegment(
new LineSegment2d(
line.StartPoint.Convert2d(plane),
line.EndPoint.Convert2d(plane))));
}
/// <summary>
/// Creates a new instance of PolylineSegmentCollection from a spline.
/// </summary>
/// <param name="spline">A spline instance.</param>
public PolylineSegmentCollection(Spline spline)
{
_contents.AddRange(new PolylineSegmentCollection((Polyline)spline.ToPolyline()));
}
/// <summary>
/// Creates a new instance of PolylineSegmentCollection from an arc.
/// </summary>
/// <param name="spline">An Arc instance.</param>
public PolylineSegmentCollection(Arc arc)
{
Plane plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
_contents.Add(new PolylineSegment(
new CircularArc2d(
arc.Center.Convert2d(plane),
arc.Radius,
arc.StartAngle,
arc.EndAngle,
Vector2d.XAxis,
false)));
}
Hi,
Some geometry extensions methods for Point2d, Point3d, CircularArc2d, Polyline and Polyline2d classes and two little (maybe usefull) classes: Triangle2d, Triangle3d.
All these classes work together and have to be compiled in a single DLL.
The extension methods requires to reference System.Core (.NET Framework 3.5)
EDIT: extended
The GeomExt class, contains the following extension methods:
Matrix3d Editor.UCS2WCS()
Matrix3d Editor.WCS2UCS()
Matrix3d Editor.DCS2WCS()
Matrix3d Editor.WCS2DCS()
Matrix3d Editor.DCS2PSDCS()
Matrix3d Editor.PSDCS2DCS()
Matrix3d Viewport.DCS2WCS()
Matrix3d Viewport.WCS2DCS()
Matrix3d Viewport.PSDCS2DCS()
Matrix3d Viewport.DCS2PSDCS()
Point3d Point2d.Convert3d()
Point3d Point2d.Convert3d(Plane plane)
Point3d Point2d.Convert3d(Vector3d normal, double elevation)
Point2d Point2d.Flatten(Vector3d normal)
bool IsBetween(Point2d p1, Point2d p2)
bool IsBetween(Point2d p1, Point2d p2, Tolerance tol)
Point2d Point2d.Polar(double angle, double distance)
Point3d Point3d.Convert2d()
Point3d Point3d.Flatten()
bool IsBetween(Point3d p1, Point3d p2)
bool IsBetween(Point3d p1, Point3d p2, Tolerance tol)
Point3d Point3d.Polar(double angle, double distance)
Point3d Point3d.Trans(int from, int to)
Point3d Point3d.Trans(Editor ed, int from, int to)
Point3d Point3d.Trans(CoordSystem from, CoordSystem to)
Point3d Point3d.Trans(Editor ed, CoordSystem from, CoordSystem to)
Vector3d Vector3d .Flatten()
void Point2dCollection.RemoveDuplicate()
void Point2dCollection.RemoveDuplicate(Tolerance tol)
bool Point2dCollection.Contains(Point2d pt, Tolerance tol)
void Point3dCollection.RemoveDuplicate()
void Point3dCollection.RemoveDuplicate(Tolerance tol)
bool Point3dCollection.Contains(Point3d pt, Tolerance tol)
double CircularArc2d.AlgebricArea()
Point2d CircularArc2d.Centroid()
Point2d Polyline.Centroid2d()
Point3d Polyline.Centroid()
Polyline Polyline.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline.GetOrthoProjectedPolyline(Plane plane)
Point3d Polyline2d.Centroid()
CircularArc3d Polyline2d.GetArcSegmentAt(int index)
CircularArc2d Polyline2d.GetArcSegment2dAt(int index)
LineSegment3d Polyline2d.GetLineSegmentAt(int index)
LineSegment2d Polyline2d.GetLineSegment2dAt(int index)
Polyline Polyline2d.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline2d.GetOrthoProjectedPolyline(Plane plane)
List<Vertex2d> Polyline2d.GetVertices()
Polyline Polyline3d.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline3d.GetOrthoProjectedPolyline(Plane plane)
Point3d Region.Centroid()
Point3d Spline.Centroid()
Polyline Ellipse.ToPolyline()
Triangle<T> abstract class
Constructors
Triangle()
Triangle(T[] pts)
Triangle(T a, T b, T c)
Indexor
T Item
Methods
T Inverse()
void Set(T[] pts)
void Set(T a, T b, T c)
T[] ToArray()
Triangle2d : Triangle<Point2d> class
Constructors
Triangle2d() : base()
Triangle2d(Point2d[] pts) : base(pts)
Triangle2d(Point2d a, Point2d b, Point2d c) : base(a, b, c)
Triangle2d(Point2d org, Vector2d v1, Vector2d v2)
Properties
double AlgebricArea
Point2d Centroid
CircularArc2d CircumscribedCircle
CircularArc2d InscribedCircle
bool IsClockwise
Methods
Triangle3d Convert3d(Plane plane)
Triangle3d Convert3d(Vector3d normal, double elevation)
double GetAngleAt(int index)
LineSegment2d GetSegmentAt(int index)
List<Point2d> IntersectWith(LinearEntity2d le2d)
List<Point2d> IntersectWith(LinearEntity2d le2d, Tolerance tol)
bool IsEqualTo(Triangle2d t2d)
bool IsEqualTo(Triangle2d t2d, Tolerance tol)
bool IsPointInside(Point2d pt)
bool IsPointOn(Point2d pt)
void Set(Point2d org, Vector2d v1, Vector2d v2)
Triangle2d TransformBy(Matrix2d mat)
Triangle3d : Triangle<Point3d> class
Constructors
Triangle3d() : base()
Triangle3d(Point3d[] pts) : base(pts)
Triangle3d(Point3d a, Point3d b, Point3d c) : base(a, b, c)
Triangle3d(Point3d org, Vector3d v1, Vector3d v2)
Properties
double Area
Point3d Centroid
CircularArc3d CircumscribedCircle
double Elevation
Vector3d GreatestSlope
Vector3d Horizontal
CircularArc3d InscribedCircle
bool IsHorizontal
Vector3d Normal
double SlopePerCent
Matrix3d SlopeUCS
Methods
Triangle2d Convert2d()
Triangle2d Flatten()
double GetAngleAt(int index)
BoundedPlane GetBoundedPlane()
Plane GetPlane()
LineSegment3d GetSegmentAt(int index)
bool IsEqualTo(Triangle3d t3d)
bool IsEqualTo(Triangle3d t3d, Tolerance tol)
bool IsPointInside(Point3d pt)
bool IsPointOn(Point3d pt)
void Set(Point3d org, Vector3d v1, Vector3d v2)
Triangle3d Transformby(Matrix3d mat)
PolylineSegment class
Constructors
PolylineSegment(Point2d startPoint, Point2d endPoint)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double constantWidth)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double startWidth, double endWidth)
PolylineSegment(Line2dSegment line)
PolylineSegment(CircularArc2d arc)
Properties
double Bulge
Point2d EndPoint
double EndWidth
bool IsLinear
Point2d StartPoint
double StartWidth
Methods
bool Equals(object obj)
PolylineSegment Clone()
int GetHashCode()
double GetParameterOf(Point3d pt)
void Inverse()
CircularArc2d ToCircularArc()
Curve2d ToCurve2d()
LineSegment2d ToLineSegment()
string ToString()
PolylineSegmentCollection : IList<PolylineSegment> class
Constructors
PolylineSegmentCollection()
PolylineSegmentCollection(Circle circle)
PolylineSegmentCollection(Ellipse ellipse)
PolylineSegmentCollection(Polyline pline)
PolylineSegmentCollection(Polyline2d pline)
PolylineSegmentCollection(IEnumerable<PolylineSegment> segments)
Methods
void Add(PolylineSegment segment)
void AddRange(IEnumerable<PolylineSegment> range)
void Clear()
bool Contains(PolylineSegment segment)
int FinIindex(Predicate<PolylineSegment> match)
int GetClosestSegmentTo(Point2d pt)
IEnumerator<PolylineSegment> GetEnumerator()
int IndexOf(PolylineSegment item)
void Insert(int index, PolylineSegment item)
void InsertRange(int index, IEnumerable<PolylineSegment> collection)
List<PolylineSegmentCollection> Join()
List<PolylineSegmentCollection> Join(Tolerance tol)
bool Remove(PolylineSegment item)
void RemoveAt(int index)
public void RemoveRange(int index, int count)
Polyline ToPolyline()
For more information, see the attached documentation.
GeomExtDoc.zip contains a .chm documentation file.
GeometryExtensions(1.6).zip contains the C# source code files and the DLLs (GeometryExtensions_18.dll for A2010-2012 and GeometryExtensions_19 for A2013+)
<EDIT: version 1.6> added CircularArc2d and CircularArc3d GetTangentsTo methods, reorganized: one class per extended type.
public static Point3d[] GetPolylinePoints(this Polyline pline)
{
int vn = pline.NumberOfVertices;
Point3d[] pointsInPolyline = new Point3d[vn];
for (int i = 0; i < vn; i++)
{
Point3d pt = pline.GetPoint3dAt(i);
pointsInPolyline[i] = pt;
}
return pointsInPolyline;
}
Hi,
Some geometry extensions methods for Point2d, Point3d, CircularArc2d, Polyline and Polyline2d classes and two little (maybe usefull) classes: Triangle2d, Triangle3d.
All these classes work together and have to be compiled in a single DLL.
The extension methods requires to reference System.Core (.NET Framework 3.5)
EDIT: extended
The GeomExt class, contains the following extension methods:
Matrix3d Editor.UCS2WCS()
Matrix3d Editor.WCS2UCS()
Matrix3d Editor.DCS2WCS()
Matrix3d Editor.WCS2DCS()
Matrix3d Editor.DCS2PSDCS()
Matrix3d Editor.PSDCS2DCS()
Matrix3d Viewport.DCS2WCS()
Matrix3d Viewport.WCS2DCS()
Matrix3d Viewport.PSDCS2DCS()
Matrix3d Viewport.DCS2PSDCS()
Point3d Point2d.Convert3d()
Point3d Point2d.Convert3d(Plane plane)
Point3d Point2d.Convert3d(Vector3d normal, double elevation)
Point2d Point2d.Flatten(Vector3d normal)
bool IsBetween(Point2d p1, Point2d p2)
bool IsBetween(Point2d p1, Point2d p2, Tolerance tol)
Point2d Point2d.Polar(double angle, double distance)
Point3d Point3d.Convert2d()
Point3d Point3d.Flatten()
bool IsBetween(Point3d p1, Point3d p2)
bool IsBetween(Point3d p1, Point3d p2, Tolerance tol)
Point3d Point3d.Polar(double angle, double distance)
Point3d Point3d.Trans(int from, int to)
Point3d Point3d.Trans(Editor ed, int from, int to)
Point3d Point3d.Trans(CoordSystem from, CoordSystem to)
Point3d Point3d.Trans(Editor ed, CoordSystem from, CoordSystem to)
Vector3d Vector3d .Flatten()
void Point2dCollection.RemoveDuplicate()
void Point2dCollection.RemoveDuplicate(Tolerance tol)
bool Point2dCollection.Contains(Point2d pt, Tolerance tol)
void Point3dCollection.RemoveDuplicate()
void Point3dCollection.RemoveDuplicate(Tolerance tol)
bool Point3dCollection.Contains(Point3d pt, Tolerance tol)
double CircularArc2d.AlgebricArea()
Point2d CircularArc2d.Centroid()
Point2d Polyline.Centroid2d()
Point3d Polyline.Centroid()
Polyline Polyline.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline.GetOrthoProjectedPolyline(Plane plane)
Point3d Polyline2d.Centroid()
CircularArc3d Polyline2d.GetArcSegmentAt(int index)
CircularArc2d Polyline2d.GetArcSegment2dAt(int index)
LineSegment3d Polyline2d.GetLineSegmentAt(int index)
LineSegment2d Polyline2d.GetLineSegment2dAt(int index)
Polyline Polyline2d.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline2d.GetOrthoProjectedPolyline(Plane plane)
List<Vertex2d> Polyline2d.GetVertices()
Polyline Polyline3d.GetProjectedPolyline(Plane plane, Vector3d direction)
Polyline Polyline3d.GetOrthoProjectedPolyline(Plane plane)
Point3d Region.Centroid()
Point3d Spline.Centroid()
Polyline Ellipse.ToPolyline()
Triangle<T> abstract class
Constructors
Triangle()
Triangle(T[] pts)
Triangle(T a, T b, T c)
Indexor
T Item
Methods
T Inverse()
void Set(T[] pts)
void Set(T a, T b, T c)
T[] ToArray()
Triangle2d : Triangle<Point2d> class
Constructors
Triangle2d() : base()
Triangle2d(Point2d[] pts) : base(pts)
Triangle2d(Point2d a, Point2d b, Point2d c) : base(a, b, c)
Triangle2d(Point2d org, Vector2d v1, Vector2d v2)
Properties
double AlgebricArea
Point2d Centroid
CircularArc2d CircumscribedCircle
CircularArc2d InscribedCircle
bool IsClockwise
Methods
Triangle3d Convert3d(Plane plane)
Triangle3d Convert3d(Vector3d normal, double elevation)
double GetAngleAt(int index)
LineSegment2d GetSegmentAt(int index)
List<Point2d> IntersectWith(LinearEntity2d le2d)
List<Point2d> IntersectWith(LinearEntity2d le2d, Tolerance tol)
bool IsEqualTo(Triangle2d t2d)
bool IsEqualTo(Triangle2d t2d, Tolerance tol)
bool IsPointInside(Point2d pt)
bool IsPointOn(Point2d pt)
void Set(Point2d org, Vector2d v1, Vector2d v2)
Triangle2d TransformBy(Matrix2d mat)
Triangle3d : Triangle<Point3d> class
Constructors
Triangle3d() : base()
Triangle3d(Point3d[] pts) : base(pts)
Triangle3d(Point3d a, Point3d b, Point3d c) : base(a, b, c)
Triangle3d(Point3d org, Vector3d v1, Vector3d v2)
Properties
double Area
Point3d Centroid
CircularArc3d CircumscribedCircle
double Elevation
Vector3d GreatestSlope
Vector3d Horizontal
CircularArc3d InscribedCircle
bool IsHorizontal
Vector3d Normal
double SlopePerCent
Matrix3d SlopeUCS
Methods
Triangle2d Convert2d()
Triangle2d Flatten()
double GetAngleAt(int index)
BoundedPlane GetBoundedPlane()
Plane GetPlane()
LineSegment3d GetSegmentAt(int index)
bool IsEqualTo(Triangle3d t3d)
bool IsEqualTo(Triangle3d t3d, Tolerance tol)
bool IsPointInside(Point3d pt)
bool IsPointOn(Point3d pt)
void Set(Point3d org, Vector3d v1, Vector3d v2)
Triangle3d Transformby(Matrix3d mat)
PolylineSegment class
Constructors
PolylineSegment(Point2d startPoint, Point2d endPoint)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double constantWidth)
PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double startWidth, double endWidth)
PolylineSegment(Line2dSegment line)
PolylineSegment(CircularArc2d arc)
Properties
double Bulge
Point2d EndPoint
double EndWidth
bool IsLinear
Point2d StartPoint
double StartWidth
Methods
bool Equals(object obj)
PolylineSegment Clone()
int GetHashCode()
double GetParameterOf(Point3d pt)
void Inverse()
CircularArc2d ToCircularArc()
Curve2d ToCurve2d()
LineSegment2d ToLineSegment()
string ToString()
PolylineSegmentCollection : IList<PolylineSegment> class
Constructors
PolylineSegmentCollection()
PolylineSegmentCollection(Circle circle)
PolylineSegmentCollection(Ellipse ellipse)
PolylineSegmentCollection(Polyline pline)
PolylineSegmentCollection(Polyline2d pline)
PolylineSegmentCollection(IEnumerable<PolylineSegment> segments)
Methods
void Add(PolylineSegment segment)
void AddRange(IEnumerable<PolylineSegment> range)
void Clear()
bool Contains(PolylineSegment segment)
int FinIindex(Predicate<PolylineSegment> match)
int GetClosestSegmentTo(Point2d pt)
IEnumerator<PolylineSegment> GetEnumerator()
int IndexOf(PolylineSegment item)
void Insert(int index, PolylineSegment item)
void InsertRange(int index, IEnumerable<PolylineSegment> collection)
List<PolylineSegmentCollection> Join()
List<PolylineSegmentCollection> Join(Tolerance tol)
bool Remove(PolylineSegment item)
void RemoveAt(int index)
public void RemoveRange(int index, int count)
Polyline ToPolyline()
For more information, see the attached documentation.
GeomExtDoc.zip contains a .chm documentation file.
GeometryExtensions(1.6).zip contains the C# source code files and the DLLs (GeometryExtensions_18.dll for A2010-2012 and GeometryExtensions_19 for A2013+)
<EDIT: version 1.6> added CircularArc2d and CircularArc3d GetTangentsTo methods, reorganized: one class per extended type.