本文整理汇总了C#中Point2d类的典型用法代码示例。如果您正苦于以下问题:C# Point2d类的具体用法?C# Point2d怎么用?C# Point2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2d类属于命名空间,在下文中一共展示了Point2d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Leader
public static Result Leader(RhinoDoc doc)
{
var points = new Point3d[]
{
new Point3d(1, 1, 0),
new Point3d(5, 1, 0),
new Point3d(5, 5, 0),
new Point3d(9, 5, 0)
};
var xy_plane = Plane.WorldXY;
var points2d = new List<Point2d>();
foreach (var point3d in points)
{
double x, y;
if (xy_plane.ClosestParameter(point3d, out x, out y))
{
var point2d = new Point2d(x, y);
if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
points2d.Add(point2d);
}
}
doc.Objects.AddLeader(xy_plane, points2d);
doc.Views.Redraw();
return Result.Success;
}
示例2: AddLinearDimension2
public static Rhino.Commands.Result AddLinearDimension2(Rhino.RhinoDoc doc)
{
Point3d origin = new Point3d(1,1,0);
Point3d offset = new Point3d(11,1,0);
Point3d pt = new Point3d((offset.X-origin.X)/2,3,0);
Plane plane = Plane.WorldXY;
plane.Origin = origin;
double u,v;
plane.ClosestParameter(origin, out u, out v);
Point2d ext1 = new Point2d(u, v);
plane.ClosestParameter(offset, out u, out v);
Point2d ext2 = new Point2d(u, v);
plane.ClosestParameter(pt, out u, out v);
Point2d linePt = new Point2d(u, v);
LinearDimension dimension = new LinearDimension(plane, ext1, ext2, linePt);
if (doc.Objects.AddLinearDimension(dimension) != Guid.Empty)
{
doc.Views.Redraw();
return Rhino.Commands.Result.Success;
}
return Rhino.Commands.Result.Failure;
}
示例3: Get
public static double Get(bool IsLeftComp, double r, Polyline line, Point2d TheIntersectPoint, int Index, Point2d StartPoint)
{
double oldBulge = line.GetBulgeAt(Index - 1);
if (oldBulge == 0)
return 0;//这里可能不对,可能有两个交点,而默认为一个交点
else
{
double delta = System.Math.Atan(System.Math.Abs(oldBulge)) * 2;
//这里计算新的半径时,要考虑方向因素,可能新半径会更小,也可能会更大
//取决于路径的偏移方向,以及圆心的位置
double newRadius = line.GetPoint2dAt(Index - 1).GetDistanceTo(line.GetPoint2dAt(Index)) / 2 / System.Math.Sin(delta);//新弧的半径
if (IsLeftComp)
{
if (oldBulge < 0)
newRadius += r;
else newRadius -= r;
}
else
{
if (oldBulge > 0)
newRadius += r;
else newRadius -= r;
}
double newChord = StartPoint.GetDistanceTo(TheIntersectPoint);
double newBulge = System.Math.Tan(
System.Math.Asin(newChord / 2 / newRadius) / 2
)
* line.GetBulgeAt(Index - 1) / System.Math.Abs(line.GetBulgeAt(Index - 1));
return -newBulge;
}
}
示例4: PolylineSegment
/// <summary>
/// Creates a new instance of PolylineSegment from two points, a bulge, a start width and an end width.
/// </summary>
/// <param name="startPoint">The start point of the segment.</param>
/// <param name="endPoint">The end point of the segment.</param>
/// <param name="bulge">The bulge of the segment.</param>
/// <param name="startWidth">The start width of the segment.</param>
/// <param name="endWidth">The end width of the segment.</param>
public PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double startWidth, double endWidth)
{
_startPoint = startPoint;
_endPoint = endPoint;
_bulge = bulge;
_startWidth = startWidth;
_endWidth = endWidth;
}
示例5: OnDynamicDraw
protected override void OnDynamicDraw(GetPointDrawEventArgs e)
{
base.OnDynamicDraw(e);
var xform = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen);
var current_point = e.CurrentPoint;
current_point.Transform(xform);
var screen_point = new Point2d(current_point.X, current_point.Y);
var msg = string.Format("screen {0:F}, {1:F}", current_point.X, current_point.Y);
e.Display.Draw2dText(msg, System.Drawing.Color.Blue, screen_point, false);
}
示例6: Imagen
public Imagen(Point2d rect, Point3d centerImage, List<Color> colors, double sizePixels)
{
this.rect = rect;
this.centerImage = centerImage;
this.colors = colors;
this.sizePixels = sizePixels;
this.pixels = new List<Pixel>();
this.ents = new List<Entity>();
PixelsConfig();
}
示例7: Sierpinski
public Sierpinski(Point3d center, Double size = 100)
{
Triangle = new Polyline();
this.Size = size;
A = new Point2d(center.X - size / 2, center.Y);
B = new Point2d(center.X, center.Y + size);
C = new Point2d(center.X + size / 2, center.Y);
Triangle.AddVertexAt(0, A, 0, 0, 0);
Triangle.AddVertexAt(1, B, 0, 0, 0);
Triangle.AddVertexAt(2, C, 0, 0, 0);
Triangle.Closed = true;
depth = 0;
}
示例8: Window
public Window(
string title,
Point2d<int> position,
Size2d<int> size,
SDL.SDL_WindowFlags flags)
{
window = SDL.SDL_CreateWindow(
title,
position.X,
position.Y,
size.Width,
size.Height,
flags);
}
示例9: GetNextScanPoint
private Point2d? GetNextScanPoint()
{
Gap nextGap = null;
var delta = int.MaxValue;
foreach (var gap in _scene.Gaps)
{
if (gap.Width() <= Config.RobotWidth * Config.UnitsInMeter)
continue;
var tmpDelta = Math.Abs(gap.PositionIndex() - _robot.PositionIndex);
if (tmpDelta >= delta)
continue;
delta = tmpDelta;
nextGap = gap;
if (delta == 0)
break;
}
if (nextGap == null)
return null;
//TODO: Возможен баг, если угол Gap больше 180 градусов
var gapWidth = nextGap.Width();
//if (gapWidth <= Config.RobotWidth * Config.UnitsInMeter)
// continue;
//var l1 = Logic.Distance(_robot.Position, nextGap.Item1.GetPoint2D());
//var p1 = Logic.GetDividingPoint(_robot.Position, nextGap.Item1.GetPoint2D(), 1 / l1);
//var l2 = Logic.Distance(_robot.Position, nextGap.Item2.GetPoint2D());
//var p2 = Logic.GetDividingPoint(_robot.Position, nextGap.Item2.GetPoint2D(), 1 / l2);
//var intersection = Logic.LineIntersection(p1, p2, nextGap.Item1.GetPoint2D(), nextGap.Item2.GetPoint2D());
//var gapWidth = Logic.Distance(p1, p2);
//TODO: подумать
//var gapWidth = nextGap.Width();
//if (gapWidth <= Config.RobotWidth * Config.UnitsInMeter)
// throw new Exception("Ширина пробела меньше ширины робота");
var coef = Math.Min(Config.CameraMaxDistance * Config.UnitsInMeter / gapWidth, 0.5);
var vector = new Point2d(nextGap.Item2.X - nextGap.Item1.X, nextGap.Item2.Y - nextGap.Item1.Y);
return new Point2d(nextGap.Item1.X + coef * vector.X, nextGap.Item1.Y + coef * vector.Y);
}
示例10: TileContour
public static void TileContour()
{
AcadLib.CommandStart.Start((doc) =>
{
Database db = doc.Database;
Editor ed = doc.Editor;
// Jig отрисовки полилинии по задаваемым точкам.
TileLineJig jigTest = new TileLineJig();
PromptResult jigRes;
bool status = true;
do
{
jigRes = ed.Drag(jigTest);
if (jigRes.Status == PromptStatus.OK)
{
// Добавление указанной точки
jigTest.AddNewPromptPoint();
}
else if (jigRes.Status == PromptStatus.Cancel || jigRes.Status == PromptStatus.Error)
{
return;
}
else if (jigRes.Status == PromptStatus.Other)
{
status = false;
}
} while (status);
// Добавление полилинии в чертеж.
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();
pl.SetDatabaseDefaults();
for (int i = 0; i < jigTest.AllVertex.Count; i++)
{
Point3d pt3d = jigTest.AllVertex[i];
Point2d pt2d = new Point2d(pt3d.X, pt3d.Y);
pl.AddVertexAt(i, pt2d, 0, db.Plinewid, db.Plinewid);
}
pl.TransformBy(jigTest.UCS);
btr.AppendEntity(pl);
tr.AddNewlyCreatedDBObject(pl, true);
tr.Commit();
}
});
}
示例11: LineIntersection
public static Point2d? LineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4)
{
var dx12 = p2.X - p1.X;
var dy12 = p2.Y - p1.Y;
var dx34 = p4.X - p3.X;
var dy34 = p4.Y - p3.Y;
var denominator = (dy12 * dx34 - dx12 * dy34);
var t1 = ((p1.X - p3.X) * dy34 + (p3.Y - p1.Y) * dx34) / denominator;
if (double.IsInfinity(t1))
return null;
return new Point2d(p1.X + dx12 * t1, p1.Y + dy12 * t1);
}
示例12: Create
public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t)
{
var cellWidth = ColorBookHelper.CellWidth;
var cellHeight = ColorBookHelper.CellHeight;
var margin = ColorBookHelper.Margin;
var marginHalf = margin * 0.5;
Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0);
Polyline pl = new Polyline(4);
pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0);
pl.Closed = true;
pl.SetDatabaseDefaults();
pl.Color = Color;
cs.AppendEntity(pl);
t.AddNewlyCreatedDBObject(pl, true);
Hatch h = new Hatch();
h.SetDatabaseDefaults();
h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
h.Annotative = AnnotativeStates.False;
cs.AppendEntity(h);
t.AddNewlyCreatedDBObject(h, true);
h.Associative = true;
h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
h.Color = Color;
h.EvaluateHatch(true);
DBText text = new DBText();
text.SetDatabaseDefaults();
text.HorizontalMode = TextHorizontalMode.TextCenter;
text.Annotative = AnnotativeStates.False;
text.Height = ColorBookHelper.TextHeight;
text.AlignmentPoint = ptText;
text.AdjustAlignment(cs.Database);
text.TextStyleId = ColorBookHelper.IdTextStylePik;
text.TextString = Name;
cs.AppendEntity(text);
t.AddNewlyCreatedDBObject(text, true);
}
示例13: closestPointOnSurf
public static DPoint3d closestPointOnSurf(DPoint3d point, ISurface surf, double tol, out double Dist, out Point2d UV, out DVector3d normal)
{
Bentley.Interop.MicroStationDGN.Point3d cpRef = new Bentley.Interop.MicroStationDGN.Point3d();
cpRef.X = point.X;
cpRef.Y = point.Y;
cpRef.Z = point.Z;
Bentley.Interop.MicroStationDGN.Point3d cp = new Bentley.Interop.MicroStationDGN.Point3d();
Bentley.Interop.MicroStationDGN.Point2d cp2d = new Bentley.Interop.MicroStationDGN.Point2d();
Dist = GeometryTools.BSplineSurfaceComputeMinimumDistance(ref cp, ref cp2d, ref cpRef, tol, surf.com_bsplineSurface);
UV = new Point2d();
UV.X = cp2d.X;
UV.Y = cp2d.Y;
normal = NormalAtUVParameterOnSurface(surf.com_bsplineSurface, UV.X, UV.Y);
return new DPoint3d(cp.X, cp.Y, cp.Z);
}
示例14: Rectangle
/// <summary>
/// Initializes a new instance of the <see cref="Rectangle"/> class.
/// </summary>
public Rectangle(Point2d bottomLeftCorner, Point2d topRightCorner)
{
if (bottomLeftCorner == null)
throw new ArgumentNullException(nameof(bottomLeftCorner));
if (topRightCorner == null)
throw new ArgumentNullException(nameof(topRightCorner));
BottomLeftCorner = bottomLeftCorner;
TopRightCorner = topRightCorner;
Width = topRightCorner.X - bottomLeftCorner.X;
Height = topRightCorner.Y - bottomLeftCorner.Y;
CenterPoint =
AddIn.CreatePoint2D(
bottomLeftCorner.X + Width / 2,
bottomLeftCorner.Y + Height / 2
);
}
示例15: addOutsides
private void addOutsides(BlockTableRecord btrPanel, Transaction t)
{
if (panelBase.Panel.outsides?.outside?.Count()>0)
{
foreach (var outside in panelBase.Panel.outsides.outside)
{
Polyline plOut = new Polyline();
Point2d pt;// =new Point2d(outside.posi.X, outside.posi.Y);
double width = Math.Abs(outside.width)+70;
// Если это левое примыкание Outside
if (Math.Abs(outside.posi.X)<10)
{
pt = new Point2d(outside.posi.X, outside.posi.Y);
panelBase.XMinContour = width;
panelBase.XStartTile = width+11;
//panelBase.XMinPanel = pt.X;
panelBase.IsOutsideLeft = true;
}
else
{
pt = new Point2d(outside.posi.X-70, outside.posi.Y);
panelBase.XMaxContour += -70;
panelBase.XMaxPanel = pt.X + width;
panelBase.IsOutsideRight = true;
}
plOut.AddVertexAt(0, pt, 0, 0, 0);
pt = new Point2d(pt.X+ width, pt.Y);
plOut.AddVertexAt(1, pt, 0, 0, 0);
pt = new Point2d(pt.X, pt.Y+outside.height);
plOut.AddVertexAt(2, pt, 0, 0, 0);
pt = new Point2d(pt.X- width, pt.Y);
plOut.AddVertexAt(3, pt, 0, 0, 0);
plOut.Closed = true;
plOut.Layer = "0";
btrPanel.AppendEntity(plOut);
t.AddNewlyCreatedDBObject(plOut, true);
}
}
}